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(
	"schedule",
	"The cron entries that osapi deploys",
	endpoint.Area(area.Config),
	endpoint.Prefix("node/{hostname}"),
	endpoint.Uses[dispatch.Deps](),
	endpoint.Tag("schedule_operations", "Schedule", "The cron entries that osapi deploys"),
	endpoint.CommandNotes("The [schedule behavior](../../../../../reference/behaviors/config/schedule/schedule.md) page tells where the behavior runs, what it is built on and its settings."),
	endpoint.Doc[types.RowStatus](dispatch.RowStatusDoc),
	endpoint.Get[ListRequest, ScheduleCollectionResponse]("list").
		Handle(HandleList).
		ID("GetNodeSchedule").
		Describe("List the cron entries that osapi deployed").
		Permission("schedule:read").
		Returns("Each target host's result.").
		Explain("Lists each file in /etc/cron.d and in /etc/cron.hourly, daily, weekly and monthly that osapi deployed, with its object, its cron expression or interval, and its user. A cron file that osapi did not deploy is not listed.").
		Example("--target web-01", "An entry that osapi deployed").
		Example("--target web-01", "A daily script that osapi deployed").
		Example("--target web-01", "A host where osapi deployed none").
		Result("An entry that osapi deployed, on one host:\n\n```ansi\n$ osapi client node schedule 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;176mOBJECT          \x1b[0m\x1b[38;2;10;143;176mSCHEDULE   \x1b[0m\x1b[38;2;10;143;176mINTERVAL  \x1b[0m\x1b[38;2;10;143;176mUSER  \x1b[0m\x1b[38;2;10;143;176mSOURCE\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m  osapitest.cron  0 2 * * *            root  cron.d\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 schedule 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;176mOBJECT          \x1b[0m\x1b[38;2;10;143;176mSCHEDULE   \x1b[0m\x1b[38;2;10;143;176mINTERVAL  \x1b[0m\x1b[38;2;10;143;176mUSER  \x1b[0m\x1b[38;2;10;143;176mSOURCE\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m  osapitest.cron  0 2 * * *            root  cron.d\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m  osapitest.cron  0 2 * * *            root  cron.d\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      \"hostname\": \"web-01\",\n      \"name\": \"osapitest\",\n      \"object\": \"osapitest.cron\",\n      \"schedule\": \"0 2 * * *\",\n      \"source\": \"cron.d\",\n      \"status\": \"ok\",\n      \"user\": \"root\"\n    }\n  ]\n}\n```\n\nA daily script that osapi deployed, on one host:\n\n```ansi\n$ osapi client node schedule 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;176mOBJECT        \x1b[0m\x1b[38;2;10;143;176mSCHEDULE  \x1b[0m\x1b[38;2;10;143;176mINTERVAL  \x1b[0m\x1b[38;2;10;143;176mUSER  \x1b[0m\x1b[38;2;10;143;176mSOURCE\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m  osapitest.sh            daily           daily\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 schedule 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;176mOBJECT        \x1b[0m\x1b[38;2;10;143;176mSCHEDULE  \x1b[0m\x1b[38;2;10;143;176mINTERVAL  \x1b[0m\x1b[38;2;10;143;176mUSER  \x1b[0m\x1b[38;2;10;143;176mSOURCE\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m  osapitest.sh            daily           daily\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m  osapitest.sh            daily           daily\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      \"hostname\": \"web-01\",\n      \"interval\": \"daily\",\n      \"name\": \"osapitest\",\n      \"object\": \"osapitest.sh\",\n      \"source\": \"daily\",\n      \"status\": \"ok\"\n    }\n  ]\n}\n```\n\nA host where osapi deployed none, on one host:\n\n```ansi\n$ osapi client node schedule list --target web-01\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;138;138;138mNone.\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node schedule list --target _all\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n\n  1 host: \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```").
		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, ScheduleGetResponse]("get").
		Handle(HandleGet).
		ID("GetNodeScheduleByKey").
		Describe("Get one cron entry that osapi deployed").
		Permission("schedule:read").
		Returns("Each target host's result.").
		Explain("Reads the entry from /etc/cron.d, then from each interval directory. An entry that osapi did not deploy is not found.").
		Example("--target web-01 --name osapitest", "An entry that osapi deployed").
		Result("An entry that osapi deployed, on one host:\n\n```ansi\n$ osapi client node schedule get --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\x1b[38;2;10;143;176mOBJECT          \x1b[0m\x1b[38;2;10;143;176mSCHEDULE   \x1b[0m\x1b[38;2;10;143;176mINTERVAL  \x1b[0m\x1b[38;2;10;143;176mUSER  \x1b[0m\x1b[38;2;10;143;176mSOURCE\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m  osapitest.cron  0 2 * * *            root  cron.d\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 schedule get --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\x1b[38;2;10;143;176mOBJECT          \x1b[0m\x1b[38;2;10;143;176mSCHEDULE   \x1b[0m\x1b[38;2;10;143;176mINTERVAL  \x1b[0m\x1b[38;2;10;143;176mUSER  \x1b[0m\x1b[38;2;10;143;176mSOURCE\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m  osapitest.cron  0 2 * * *            root  cron.d\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[1mosapitest\x1b[0m  osapitest.cron  0 2 * * *            root  cron.d\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      \"hostname\": \"web-01\",\n      \"name\": \"osapitest\",\n      \"object\": \"osapitest.cron\",\n      \"schedule\": \"0 2 * * *\",\n      \"source\": \"cron.d\",\n      \"status\": \"ok\",\n      \"user\": \"root\"\n    }\n  ]\n}\n```\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| An entry that osapi did not deploy | `--name osapitest` | not found |\n| A name with a space | `--name \"a b\"` | Name |\n| A name that is an option | `--name --now` | not a valid entry name |\n| A name over 64 characters | `--name aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` | Name |").
		Errors(endpoint.NotFound(behavior.ErrNotFound, "The host has no schedule 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, ScheduleCreateResponse]("create").
		Handle(HandleCreate).
		ID("PostNodeSchedule").
		Describe("Deploy a cron entry").
		Permission("schedule:write").
		Returns("Each target host's result, with whether it changed.").
		Explain("Gets the object from the object store and writes it as /etc/cron.d/backup for backup, mode 0644, for a cron expression, or as /etc/cron.daily/backup, mode 0755, for a daily interval. An object of content type template, or content_type template, is rendered with the agent's facts and the vars. A file that has the content does not change. An entry of the name in a different directory does not change: move it with delete and create. A file at the path that osapi did not deploy is refused. An entry runs as its user, root included, so only admin can deploy one.").
		Example("--target web-01 --name osapitest --object osapitest.cron --schedule \"0 2 * * *\" --user root", "An entry with a cron expression").
		Example("--target web-01 --name osapitest --object osapitest.sh --interval daily", "A script that runs daily").
		Example("--target web-01 --name osapitest --object osapitest.tmpl --schedule \"0 2 * * *\" --content-type template --vars target=/srv", "A template, rendered with its vars").
		Example("--target web-01 --name osapitest --object osapitest.cron --schedule \"0 2 * * *\" --user root", "An entry that has the content").
		Example("--target web-01 --name osapitest --object osapitest.sh --interval daily", "An entry of the name in a different directory").
		Result("An entry with a cron expression, on one host:\n\n```ansi\n$ osapi client node schedule create --target web-01 --name osapitest --object osapitest.cron --schedule \"0 2 * * *\" --user 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 schedule create --target _all --name osapitest --object osapitest.cron --schedule \"0 2 * * *\" --user 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\nA script that runs daily, on one host:\n\n```ansi\n$ osapi client node schedule create --target web-01 --name osapitest --object osapitest.sh --interval daily\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 schedule create --target _all --name osapitest --object osapitest.sh --interval daily\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 template, rendered with its vars, on one host:\n\n```ansi\n$ osapi client node schedule create --target web-01 --name osapitest --object osapitest.tmpl --schedule \"0 2 * * *\" --content-type template --vars target=/srv\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 schedule create --target _all --name osapitest --object osapitest.tmpl --schedule \"0 2 * * *\" --content-type template --vars target=/srv\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\nAn entry that has the content, on one host:\n\n```ansi\n$ osapi client node schedule create --target web-01 --name osapitest --object osapitest.cron --schedule \"0 2 * * *\" --user 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 schedule create --target _all --name osapitest --object osapitest.cron --schedule \"0 2 * * *\" --user 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\nAn entry of the name in a different directory, on one host:\n\n```ansi\n$ osapi client node schedule create --target web-01 --name osapitest --object osapitest.sh --interval daily\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 schedule create --target _all --name osapitest --object osapitest.sh --interval daily\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| An entry with a cron expression | writes `/etc/cron.d/osapitest`: `0 2 * * * root /usr/local/bin/backup` |\n| A script that runs daily | writes `/etc/cron.daily/osapitest`: `#!/bin/sh\\n/usr/local/bin/backup` |\n| A template, rendered with its vars | writes `/etc/cron.d/osapitest`: `0 2 * * * root /usr/local/bin/backup /srv` |\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| An object the store does not have | `--name osapitest --object nosuch --schedule \"0 2 * * *\"` | not found |\n| A template that reads a var the request does not give | `--name osapitest --object osapitest.tmpl --schedule \"0 2 * * *\" --content-type template` | render template |\n| A file that osapi did not deploy | `--name osapitest --object osapitest.cron --schedule \"0 2 * * *\"` | osapi did not deploy it |\n| No object | `--name osapitest --schedule \"0 2 * * *\"` | Object |\n| Neither a cron expression nor an interval | `--name osapitest --object osapitest.cron` | Schedule |\n| A cron expression and an interval | `--name osapitest --object osapitest.cron --schedule \"0 2 * * *\" --interval daily` | Schedule |\n| A cron expression that does not parse | `--name osapitest --object osapitest.cron --schedule \"every day\"` | Schedule |\n| An interval that is not one | `--name osapitest --object osapitest.cron --interval yearly` | Interval |\n| A name with a slash | `--name a/b --object osapitest.cron --schedule \"0 2 * * *\"` | Name |\n| A name that is an option | `--name --now --object osapitest.cron --schedule \"0 2 * * *\"` | not a valid entry name |\n| A name over 64 characters | `--name aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa --object osapitest.cron --schedule \"0 2 * * *\"` | Name |\n| An object name over 255 characters | `--name osapitest --object aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa --schedule \"0 2 * * *\"` | Object |\n| A user that is not an account name | `--name osapitest --object osapitest.cron --schedule \"0 2 * * *\" --user \"a b\"` | User |\n| A content type that is not one | `--name osapitest --object osapitest.cron --schedule \"0 2 * * *\" --content-type zip` | ContentType |").
		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, ScheduleUpdateResponse]("update").
		Handle(HandleUpdate).
		ID("PutNodeSchedule").
		Describe("Deploy a cron entry that osapi deployed again").
		Permission("schedule:write").
		Returns("Each target host's result, with whether it changed.").
		Explain("Writes a new object, or the entry's own, at the entry's path, with the fields that the request gives and the entry's own for the rest. A file that has the content does not change. An entry that osapi did not deploy is not found. The entry stays in its directory: an interval does not change with update.").
		Example("--target web-01 --name osapitest --object osapitest-v2.cron", "A new object").
		Example("--target web-01 --name osapitest --schedule \"30 2 * * *\"", "A new cron expression, with the same object").
		Example("--target web-01 --name osapitest --object osapitest-v2.cron --schedule \"30 2 * * *\" --user nobody", "A new object, cron expression and user").
		Example("--target web-01 --name osapitest --object osapitest-v2.sh", "A daily script with a new object").
		Result("A new object, on one host:\n\n```ansi\n$ osapi client node schedule update --target web-01 --name osapitest --object osapitest-v2.cron\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 schedule update --target _all --name osapitest --object osapitest-v2.cron\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 new cron expression, with the same object, on one host:\n\n```ansi\n$ osapi client node schedule update --target web-01 --name osapitest --schedule \"30 2 * * *\"\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 schedule update --target _all --name osapitest --schedule \"30 2 * * *\"\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 new object, cron expression and user, on one host:\n\n```ansi\n$ osapi client node schedule update --target web-01 --name osapitest --object osapitest-v2.cron --schedule \"30 2 * * *\" --user nobody\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 schedule update --target _all --name osapitest --object osapitest-v2.cron --schedule \"30 2 * * *\" --user nobody\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 daily script with a new object, on one host:\n\n```ansi\n$ osapi client node schedule update --target web-01 --name osapitest --object osapitest-v2.sh\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 schedule update --target _all --name osapitest --object osapitest-v2.sh\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\nWith the default settings, each example does this on the host:\n\n| Example | On the host |\n| --- | --- |\n| A new object | writes `/etc/cron.d/osapitest`: `30 2 * * * root /usr/local/bin/backup --full` |\n| A new cron expression, with the same object | writes `/etc/cron.d/osapitest`: `0 2 * * * root /usr/local/bin/backup` |\n| A new object, cron expression and user | writes `/etc/cron.d/osapitest`: `30 2 * * * root /usr/local/bin/backup --full` |\n| A daily script with a new object | writes `/etc/cron.daily/osapitest`: `#!/bin/sh\\n/usr/local/bin/backup\\n/usr/local/bin/prune` |\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| An entry that osapi did not deploy | `--name osapitest --object osapitest.cron` | not found |\n| A cron expression that does not parse | `--name osapitest --schedule \"every day\"` | Schedule |\n| A name with a space | `--name \"a b\"` | Name |\n| A name that is an option | `--name --now` | not a valid entry name |\n| A name over 64 characters | `--name aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` | Name |\n| An object name over 255 characters | `--name osapitest --object aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` | Object |\n| A user that is not an account name | `--name osapitest --user \"a b\"` | User |\n| A content type that is not one | `--name osapitest --content-type zip` | ContentType |").
		Errors(endpoint.NotFound(behavior.ErrNotFound, "The host has no schedule 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, ScheduleDeleteResponse]("delete").
		Handle(HandleDelete).
		ID("DeleteNodeSchedule").
		Describe("Remove a cron entry that osapi deployed").
		Permission("schedule:write").
		Returns("Each target host's result, with whether it changed.").
		Explain("Removes the entry's file and its record. An entry that osapi did not deploy does not change, and a cron file that osapi did not deploy stays.").
		Example("--target web-01 --name osapitest", "Remove an entry").
		Example("--target web-01 --name osapitest", "An entry that osapi did not deploy").
		Result("Remove an entry, on one host:\n\n```ansi\n$ osapi client node schedule 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 schedule 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\nAn entry that osapi did not deploy, on one host:\n\n```ansi\n$ osapi client node schedule 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 schedule 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 an entry | removes `/etc/cron.d/osapitest` |\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| A name with a space | `--name \"a b\"` | Name |\n| A name that is an option | `--name --now` | not a valid entry name |\n| A name over 64 characters | `--name aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` | Name |").
		Errors(endpoint.NotFound(behavior.ErrNotFound, "The host has no schedule 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 schedule as an endpoint group, which its spec comes from.

Functions

func Routes

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

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

Types

type CreateRequest

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

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

type DeleteRequest

type DeleteRequest struct {
	Hostname string `` /* 182-byte string literal not displayed */
	Name     string `doc:"The entry, such as backup" in:"path" json:"name" param:"ScheduleName" validate:"required,max=64,resource_name"`
}

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

type GetRequest

type GetRequest struct {
	Hostname string `` /* 182-byte string literal not displayed */
	Name     string `doc:"The entry, such as backup" in:"path" json:"name" param:"ScheduleName" validate:"required,max=64,resource_name"`
}

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

type ListRequest

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

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

type ScheduleCollectionResponse

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

ScheduleCollectionResponse is each target host's result.

func HandleList

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

type ScheduleCreateRequest

type ScheduleCreateRequest struct {
	Name        string            `doc:"The entry, and its file name, such as backup" json:"name" validate:"required,max=64,resource_name"`
	Object      string            `doc:"The object that holds the entry, from osapi client file upload" json:"object" validate:"required,min=1,max=255"`
	Schedule    string            `` /* 175-byte string literal not displayed */
	Interval    types.Interval    `` /* 184-byte string literal not displayed */
	User        string            `doc:"The user the entry runs as" json:"user,omitempty" validate:"omitempty,account_name"`
	ContentType types.ContentType `` /* 178-byte string literal not displayed */
	Vars        map[string]string `doc:"The vars of a template, as key=value" json:"vars,omitempty" validate:"omitempty"`
}

ScheduleCreateRequest is the body of schedule create.

type ScheduleCreateResponse

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

ScheduleCreateResponse is each target host's result.

func HandleCreate

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

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

type ScheduleDeleteResponse

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

ScheduleDeleteResponse is each target host's result.

func HandleDelete

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

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

type ScheduleEntry

type ScheduleEntry 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 entry" json:"name,omitempty"`
	Object   *string         `doc:"The object it was deployed from" json:"object,omitempty"`
	Schedule *string         `doc:"Its cron expression, for an entry in /etc/cron.d" json:"schedule,omitempty"`
	Interval *string         `doc:"Its interval, for a script in /etc/cron.daily and the like" json:"interval,omitempty"`
	User     *string         `doc:"The user it runs as" json:"user,omitempty"`
	Source   *string         `doc:"Where its file is: cron.d, or the interval" json:"source,omitempty"`
	Error    *string         `doc:"Error message if the agent failed." json:"error,omitempty"`
}

ScheduleEntry is the result of schedule on one host.

type ScheduleGetResponse

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

ScheduleGetResponse is each target host's result.

func HandleGet

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

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

type ScheduleResult

type ScheduleResult 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 entry" 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"`
}

ScheduleResult is the result of schedule on one host.

type ScheduleUpdateRequest

type ScheduleUpdateRequest struct {
	Object      string            `doc:"The object to deploy; the entry's own when empty" json:"object,omitempty" validate:"omitempty,min=1,max=255"`
	Schedule    string            `doc:"A new cron expression; the entry's own when empty" json:"schedule,omitempty" validate:"omitempty,cron_schedule"`
	User        string            `doc:"The user the entry runs as; the entry's own when empty" json:"user,omitempty" validate:"omitempty,account_name"`
	ContentType types.ContentType `doc:"The content type, raw or template; the object's own when empty" json:"content_type,omitempty" validate:"omitempty,enum"`
	Vars        map[string]string `doc:"The vars of a template, as key=value" json:"vars,omitempty" validate:"omitempty"`
}

ScheduleUpdateRequest is the body of schedule update.

type ScheduleUpdateResponse

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

ScheduleUpdateResponse is each target host's result.

func HandleUpdate

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

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

type UpdateRequest

type UpdateRequest struct {
	Hostname string                `` /* 182-byte string literal not displayed */
	Name     string                `doc:"The entry, such as backup" in:"path" json:"name" param:"ScheduleName" validate:"required,max=64,resource_name"`
	Body     ScheduleUpdateRequest `in:"body" validate:"required"`
}

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

Jump to

Keyboard shortcuts

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