Download your service account credentials file from Google Cloud and save it as googlecloudinfo.json
in your HOME/.gocloud directory.
You can also set the credentials as environment variables:
export PrivateKey = "xxxxxxxxxxxx"
export Type = "xxxxxxxxxxxx"
export ProjectID = "xxxxxxxxxxxx"
export PrivateKeyID = "xxxxxxxxxxxx"
export ClientEmail = "xxxxxxxxxxxx"
export ClientID = "xxxxxxxxxxxx"
export AuthURI = "xxxxxxxxxxxx"
export TokenURI = "xxxxxxxxxxxx"
export AuthProviderX509CertURL = "xxxxxxxxxxxx"
export ClientX509CertURL = "xxxxxxxxxxxx"
import "github.com/cloudlibz/gocloud/gocloud"
googlecloud, _ := gocloud.CloudProvider(gocloud.Googleprovider)
createdns := map[string]interface{}{
"Project": "sheltermap-1493101612061",
"Kind": "dns#managedZone",
"Description": "dns",
"DnsName": "rootmonk.me.",
"Name": "gocloud",
}
resp, err := googlecloud.CreateDns(createdns)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
listdns := map[string]string{
"Project": "sheltermap-1493101612061",
}
resp, err := googlecloud.ListDns(listdns)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
deletedns := map[string]string{
"Project": "sheltermap-1493101612061",
"managedZone": "gocloud3",
}
resp, err := googlecloud.DeleteDns(deletedns)
response := resp.(map[string]interface{})
fmt.Println(response["body"])
listResourcednsRecordSets := map[string]string{
"Project" : "sheltermap-1493101612061",
"managedZone" : "gocloud3",
}
resp, err := googlecloud.ListResourceDnsRecordSets(listResourcednsRecordSets)
response := resp.(map[string]interface{})
fmt.Println(response["body"])