Skip to content
Get started

Get filesystem path info

client.Instances.Stat(ctx, id, query) (*PathInfo, error)
get/instances/{id}/stat

Returns information about a path in the guest filesystem. Useful for checking if a path exists, its type, and permissions before performing file operations.

ParametersExpand Collapse
id string
query InstanceStatParams
Path param.Field[string]

Path to stat in the guest filesystem

ReturnsExpand Collapse
type PathInfo struct{…}
Exists bool

Whether the path exists

Error stringoptional

Error message if stat failed (e.g., permission denied). Only set when exists is false due to an error rather than the path not existing.

IsDir booloptional

True if this is a directory

IsFile booloptional

True if this is a regular file

Mode int64optional

File mode (Unix permissions)

Size int64optional

File size in bytes

formatint64
Get filesystem path info
package main

import (
  "context"
  "fmt"

  "github.com/kernel/hypeman-go"
  "github.com/kernel/hypeman-go/option"
)

func main() {
  client := hypeman.NewClient(
    option.WithAPIKey("My API Key"),
  )
  pathInfo, err := client.Instances.Stat(
    context.TODO(),
    "id",
    hypeman.InstanceStatParams{
      Path: "path",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", pathInfo.Exists)
}
{
  "exists": true,
  "error": "permission denied",
  "is_dir": false,
  "is_file": true,
  "is_symlink": false,
  "link_target": "/actual/target/path",
  "mode": 420,
  "size": 1024
}
Returns Examples
{
  "exists": true,
  "error": "permission denied",
  "is_dir": false,
  "is_file": true,
  "is_symlink": false,
  "link_target": "/actual/target/path",
  "mode": 420,
  "size": 1024
}