config

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Copyright © 2025 Vapi, Inc.

Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Authors:

Dan Goosewin <[email protected]>

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveConfig

func SaveConfig(config *Config) error

func SetConfig added in v0.0.8

func SetConfig(config *Config)

SetConfig sets the global configuration instance

Types

type Account added in v0.1.2

type Account struct {
	APIKey       string `mapstructure:"apikey"`
	Organization string `mapstructure:"organization,omitempty"` // Organization name if available
	OrgID        string `mapstructure:"org_id,omitempty"`       // Organization ID for reliable deduplication
	Environment  string `mapstructure:"environment,omitempty"`  // Per-account environment override
	LoginTime    string `mapstructure:"logintime,omitempty"`    // When this account was last authenticated
	Email        string `mapstructure:"email,omitempty"`        // User email if available
}

Account represents a single authenticated account/organization

type Config

type Config struct {
	APIKey           string             `mapstructure:"api_key"` // Legacy single API key (for backward compatibility)
	BaseURL          string             `mapstructure:"base_url"`
	DashboardURL     string             `mapstructure:"dashboard_url"`
	Environment      string             `mapstructure:"environment"`
	Timeout          int                `mapstructure:"timeout"`
	DisableAnalytics bool               `mapstructure:"disable_analytics"`
	Accounts         map[string]Account `mapstructure:"accounts"`       // Multiple accounts support
	ActiveAccount    string             `mapstructure:"active_account"` // Which account is currently active
}

func GetConfig added in v0.0.8

func GetConfig() *Config

GetConfig returns the global configuration instance

func LoadConfig

func LoadConfig() (*Config, error)

func (*Config) AddAccount added in v0.1.2

func (c *Config) AddAccount(accountKey, apiKey, organization, orgID, email string)

AddAccount adds a new account or updates an existing one

func (*Config) GetAPIBaseURL added in v0.0.2

func (c *Config) GetAPIBaseURL() string

GetAPIBaseURL returns the API base URL, respecting environment overrides

func (*Config) GetAPIKeySource added in v0.1.2

func (c *Config) GetAPIKeySource() string

GetAPIKeySource returns where the current API key comes from

func (*Config) GetActiveAPIKey added in v0.1.2

func (c *Config) GetActiveAPIKey() string

GetActiveAPIKey returns the API key for the currently active account

func (*Config) GetActiveAccount added in v0.1.2

func (c *Config) GetActiveAccount() *Account

GetActiveAccount returns the currently active account

func (*Config) GetDashboardURL added in v0.0.2

func (c *Config) GetDashboardURL() string

GetDashboardURL returns the dashboard URL, respecting environment overrides

func (*Config) GetEnvironment added in v0.0.2

func (c *Config) GetEnvironment() string

GetEnvironment returns the current environment name

func (*Config) IsProduction added in v0.0.2

func (c *Config) IsProduction() bool

IsProduction returns true if running against production environment

func (*Config) ListAccounts added in v0.1.2

func (c *Config) ListAccounts() map[string]Account

ListAccounts returns all configured accounts

func (*Config) RemoveAccount added in v0.1.2

func (c *Config) RemoveAccount(accountKey string) error

RemoveAccount removes an account

func (*Config) SetActiveAccount added in v0.1.2

func (c *Config) SetActiveAccount(accountKey string) error

SetActiveAccount switches to the specified account

type Environment added in v0.0.2

type Environment struct {
	Name         string
	APIBaseURL   string
	DashboardURL string
}

Environment configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL