Skip to main content

Timezone

c.Timezone calls the API's Timezone group. The timezone of the host.

Methods​

MethodReturnsPermissionDescription
Get(ctx, hostname)*Response[Collection[TimezoneEntry]]timezone:readGet the timezone of the host.
Update(ctx, hostname, input)*Response[Collection[TimezoneResult]]timezone:writeSet the timezone of the host.

Get​

func (s *TimezoneService) Get(
ctx context.Context,
hostname string,
) (*Response[Collection[TimezoneEntry]], error)

Get the timezone of the host.

Reads the IANA name of the timezone and its offset from UTC now: the zone that /etc/localtime links to, or /etc/timezone on Linux.

It sends GET /api/node/{hostname}/timezone, and needs the permission timezone:read.

The examples of the method's definition:

A Linux host on UTC, go run timezone.go get:

resp, err := c.Timezone.Get(ctx, target)

Update​

func (s *TimezoneService) Update(
ctx context.Context,
hostname string,
input TimezoneUpdateInput,
) (*Response[Collection[TimezoneResult]], error)

Set the timezone of the host.

Sets the timezone with timedatectl set-timezone. A host that already has the timezone does not change and reports changed: false. It runs on the Debian family only, and elsewhere reports skipped.

It sends PUT /api/node/{hostname}/timezone, and needs the permission timezone:write.

The examples of the method's definition:

Set a new timezone, go run timezone.go update:

resp, err := c.Timezone.Update(ctx, target, client.TimezoneUpdateInput{Timezone: "America/New_York"})

A host that already has the timezone, go run timezone.go update-2:

resp, err := c.Timezone.Update(ctx, target, client.TimezoneUpdateInput{Timezone: "UTC"})

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.

TimezoneEntry​

FieldTypeDescription
ErrorstringError message if the agent failed.
HostnamestringHostname of the agent that produced this result.
StatusRowStatusWhat 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.
TimezonestringThe IANA name of the timezone, such as America/New_York.
UTCOffsetstringThe offset from UTC now, such as -05:00.

TimezoneResult​

FieldTypeDescription
ChangedboolWhether the host changed.
ErrorstringError message if the agent failed.
HostnamestringHostname of the agent that produced this result.
StatusRowStatusWhat 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.
TimezonestringThe timezone of the host.

TimezoneUpdateInput​

FieldTypeDescription
TimezonestringThe IANA name of the timezone, such as UTC or America/New_York.

Example​

examples/sdk/client/timezone.go runs each example of this page. With no argument, it lists them.