Skip to main content

Timezone

The Timezone service provides methods for managing the system timezone on target hosts via timedatectl. Access via client.Timezone.Get(), client.Timezone.Update().

Methods

MethodDescription
Get(ctx, hostname)Get system timezone
Update(ctx, hostname, opts)Set system timezone

Request Types

TypeFields
TimezoneUpdateOptsTimezone (required)

Usage

import "github.com/retr0h/osapi/pkg/sdk/client"

c := client.New("http://localhost:8080", token)

// Get the current timezone
resp, err := c.Timezone.Get(ctx, "web-01")
for _, r := range resp.Data.Results {
fmt.Printf("timezone=%s offset=%s\n", r.Timezone, r.UTCOffset)
}

// Update the timezone
resp, err := c.Timezone.Update(ctx, "web-01", client.TimezoneUpdateOpts{
Timezone: "America/New_York",
})
for _, r := range resp.Data.Results {
fmt.Printf("changed=%v\n", r.Changed)
}

Result Types

TimezoneResult

FieldTypeDescription
HostnamestringAgent hostname
Statusstringok, failed, or skipped
TimezonestringIANA timezone name
UTCOffsetstringUTC offset (e.g., "-05:00")
ErrorstringError message (empty on success)

TimezoneMutationResult

FieldTypeDescription
HostnamestringAgent hostname
Statusstringok, failed, or skipped
TimezonestringTimezone that was set
ChangedboolWhether state was modified
ErrorstringError message (empty on success)

Example

Permissions

OperationPermission
Gettimezone:read
Updatetimezone:write

Timezone management is supported on the Debian OS family (Ubuntu, Debian, Raspbian). On unsupported platforms (Darwin, generic Linux), operations return status: skipped.