UserPassword
c.UserPassword calls the API's UserPassword group. The password of a user.
Methods
| Method | Returns | Permission | Description |
|---|---|---|---|
Update(ctx, hostname, input) | *Response[Collection[UserPasswordResult]] | user:write | Set the password of a user. |
Update
func (s *UserPasswordService) Update(
ctx context.Context,
hostname string,
input UserPasswordUpdateInput,
) (*Response[Collection[UserPasswordResult]], error)
Set the password of a user.
Sets the password with chpasswd -e, from its hash on standard input. The controller hashes the password, so the job and NATS have only the hash. Each call makes a new hash, so it always reports changed: true. A user that the host does not have is not found. It runs on the Debian family only, and elsewhere reports skipped.
It sends PUT /api/node/{hostname}/user/{name}/password, and needs the
permission user:write.
The examples of the method's definition:
Set a password, go run user_password.go update:
resp, err := c.UserPassword.Update(ctx, target, client.UserPasswordUpdateInput{
Name: "osapitest",
Password: "-",
})
Types
The fields of each type are the properties of its schema in the API's spec.
RowStatus
What happened on the host: ok, the operation ran and succeeded; failed, it ran and did not succeed; skipped, the host's OS family does not support it; timeout, the host did not answer, so nobody knows whether it ran.
A string, one of ok, failed, skipped, timeout.
UserPasswordResult
| Field | Type | Description |
|---|---|---|
Changed | bool | Whether the host changed. |
Error | string | Error message if the agent failed. |
Hostname | string | Hostname of the agent that produced this result. |
Name | string | The user. |
Status | RowStatus | What happened on the host: ok, the operation ran and succeeded; failed, it ran and did not succeed; skipped, the host's OS family does not support it; timeout, the host did not answer, so nobody knows whether it ran. |
UserPasswordUpdateInput
| Field | Type | Description |
|---|---|---|
Name | string | The name of the path. The user, such as alice. |
Password | string | The new password, which osapi hashes on the controller. A secret: a reference, secret:// |
Example
examples/sdk/client/user_password.go
runs each example of this page. With no argument, it lists them.