Example #1
0
func New(testing bool) *Domain {
	// Load the gandi config file, which contains the api keys
	cfg := config.Load("")
	var c *client.Client
	if testing {
		c = client.New(cfg.ApiTestKey, client.Testing)
	} else {
		c = client.New(cfg.ApiProdKey, client.Production)
	}

	return &Domain{
		domain:  domain.New(c),
		zone:    zone.New(c),
		record:  record.New(c),
		version: version.New(c),
	}
}
Example #2
0
func NewGandiClient(configPath string, testing bool) *client.Client {
	// Load config
	cfg := config.Load(configPath)

	var apiKey string
	var systemType client.SystemType

	// Use test system and api key if the Testing flag was provided
	if testing {
		apiKey = cfg.ApiTestKey
		systemType = client.Testing
	} else {
		apiKey = cfg.ApiProdKey
		systemType = client.Production
	}

	// Create gandi client
	return client.New(apiKey, systemType)
}