コード例 #1
0
ファイル: update.go プロジェクト: MattiasGees/terraform
func main() {
	akey := os.Getenv("DME_AKEY")
	skey := os.Getenv("DME_SKEY")
	domainID := os.Getenv("DME_DOMAINID")
	recordID := os.Getenv("DME_RECORDID")

	fmt.Println("Using these values:")
	fmt.Println("akey:", akey)
	fmt.Println("skey:", skey)
	fmt.Println("domainid:", domainID)
	fmt.Println("recordid:", recordID)

	if len(akey) == 0 || len(skey) == 0 || len(domainID) == 0 || len(recordID) == 0 {
		log.Fatalf("Environment variable(s) not set\n")
	}

	client, err := dme.NewClient(akey, skey)
	client.URL = dme.SandboxURL
	if err != nil {
		log.Fatalf("err: %v", err)
	}

	cr := map[string]interface{}{
		"name": "test-update",
	}

	result, err2 := client.UpdateRecord(domainID, recordID, cr)
	if err2 != nil {
		log.Fatalf("UpdateRecord result: %v error %v", result, err2)
	}
	log.Print("Result: ", result)
}
コード例 #2
0
ファイル: delete.go プロジェクト: MattiasGees/terraform
func main() {
	akey := os.Getenv("DME_AKEY")
	skey := os.Getenv("DME_SKEY")
	domainID := os.Getenv("DME_DOMAINID")
	recordID := os.Getenv("DME_RECORDID")

	fmt.Println("Using these values:")
	fmt.Println("akey:", akey)
	fmt.Println("skey:", skey)
	fmt.Println("domainid:", domainID)
	fmt.Println("recordid:", recordID)

	if len(akey) == 0 || len(skey) == 0 || len(domainID) == 0 || len(recordID) == 0 {
		log.Fatalf("Environment variable(s) not set\n")
	}

	client, err := dme.NewClient(akey, skey)
	client.URL = dme.SandboxURL
	if err != nil {
		log.Fatalf("err: %v", err)
	}

	err2 := client.DeleteRecord(domainID, recordID)
	if err2 != nil {
		log.Fatalf("DeleteRecord result: %v", err2)
	}
	log.Print("Destroyed.")
}
コード例 #3
0
ファイル: config.go プロジェクト: jrperritt/terraform
// Client returns a new client for accessing DNSMadeEasy
func (c *Config) Client() (*dnsmadeeasy.Client, error) {
	client, err := dnsmadeeasy.NewClient(c.AKey, c.SKey)
	if err != nil {
		return nil, fmt.Errorf("Error setting up client: %s", err)
	}

	if c.UseSandbox {
		client.URL = dnsmadeeasy.SandboxURL
	}

	log.Printf("[INFO] DNSMadeEasy Client configured for AKey: %s", client.AKey)

	return client, nil
}
コード例 #4
0
ファイル: create.go プロジェクト: MattiasGees/terraform
func main() {
	akey := os.Getenv("DME_AKEY")
	skey := os.Getenv("DME_SKEY")
	domainID := os.Getenv("DME_DOMAINID")
	ip := os.Getenv("DME_IP")

	fmt.Println("Using these values:")
	fmt.Println("akey:", akey)
	fmt.Println("skey:", skey)
	fmt.Println("domainid:", domainID)
	fmt.Println("ip:", ip)

	if len(akey) == 0 || len(skey) == 0 || len(domainID) == 0 || len(ip) == 0 {
		log.Fatalf("Environment variable(s) not set\n")
	}

	client, err := dme.NewClient(akey, skey)
	if err != nil {
		log.Fatalf("err: %v", err)
	}
	client.URL = dme.SandboxURL

	cr := map[string]interface{}{
		"name":  "test",
		"type":  "A",
		"value": ip,
		"ttl":   86400,
	}

	result, err2 := client.CreateRecord(domainID, cr)
	if err2 != nil {
		log.Fatalf("Result: '%s' Error: %s", result, err2)
	}

	log.Printf("Result: '%s'", result)
}