added slapapi

This commit is contained in:
2026-02-17 08:12:07 +11:00
parent 317fb9a070
commit 35eb2e695a
14 changed files with 427 additions and 46 deletions

23
pkg/slapshotapi/config.go Normal file
View File

@@ -0,0 +1,23 @@
// Package slapshotapi provides utilities for interacting with the slapshot public API
package slapshotapi
import (
"git.haelnorr.com/h/golib/env"
"github.com/pkg/errors"
)
type Config struct {
Environment string // ENV SLAPSHOT_ENVIRONMENT: API environment to connect to (default: staging)
Key string // ENV SLAPSHOT_API_KEY: API Key for authorisation with the API (required)
}
func ConfigFromEnv() (any, error) {
cfg := &Config{
Environment: env.String("SLAPSHOT_ENVIRONMENT", "staging"),
Key: env.String("SLAPSHOT_API_KEY", ""),
}
if cfg.Key == "" {
return nil, errors.New("Envar not set: SLAPSHOT_API_KEY")
}
return cfg, nil
}