Skip to content

Conversation

@vincentjanv
Copy link

This pull request introduces greater configurability and flexibility to the API endpoint and country selection logic throughout the CLI tool. The most significant changes are the introduction of environment variable overrides for the Vicohome API base URL and country code, and the refactoring of all HTTP requests to use these dynamic values. This makes the CLI more adaptable to different environments or regions without requiring code changes.

Configurability improvements:

  • Added a GetBaseURL() function in pkg/auth/auth.go, cmd/devices/root.go, and cmd/events/root.go to allow the API base URL to be set via the VICOHOME_BASE_URL environment variable, defaulting to "https://api-us.vicohome.io" if not set. All HTTP requests in device and event commands now use this function to construct their URLs. [1] [2] [3] [4] [5] [6] [7] [8]

  • Added a GetCountry() function in cmd/devices/list.go to allow the country code to be set via the VICOHOME_COUNTRY environment variable, defaulting to "US" if not set. The device list request now uses this function for the CountryNo parameter.

Dependency and import updates:

  • Added os package imports in files where environment variable access is required. [1] [2] [3]

These changes make the CLI more robust for multi-region or custom deployments and improve maintainability by centralizing configuration logic.

Introduces environment variables for base URL and country.
Uses the environment variables if set, otherwise defaults to US region.

This allows the CLI to be used with different Vicohome regions.
@vincentjanv
Copy link
Author

Requested by #12

@vincentjanv vincentjanv changed the title Adds region support Adds region support as requested in #12 Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant