예제 #1
0
func InstancesList(tags string) (json *gabs.Container, err error) {
	if tags != "" {
		return makeJSONCall(config.URL()+"/v1/instances?tags="+tags, HTTPGet, "")
	} else {
		return makeJSONCall(config.URL()+"/v1/instances", HTTPGet, "")
	}
}
예제 #2
0
func QuotaGet(account string) (json *gabs.Container, err error) {
	if account != "" {
		return makeJSONCall(config.URL()+"/v1/quota?username="******"")
	} else {
		return makeJSONCall(config.URL()+"/v1/quota", HTTPGet, "")
	}
}
예제 #3
0
func InstanceReboot(id string, hard bool) (json *gabs.Container, err error) {
	if hard {
		return makeJSONCall(config.URL()+"/v1/instances/"+id+"/hard_reboots", HTTPPost, "")
	} else {
		return makeJSONCall(config.URL()+"/v1/instances/"+id+"/soft_reboots", HTTPPost, "")
	}
}
예제 #4
0
func SnapshotCreate(name, instance_id string, safe bool) (json *gabs.Container, err error) {
	saveVal := "false"
	if safe {
		saveVal = "true"
	}
	return makeJSONCall(config.URL()+"/v1/snapshots/"+name, HTTPPut, "instance_id="+instance_id+"&safe="+saveVal)
}
예제 #5
0
파일: ips.go 프로젝트: absolutedevops/civo
func IPCreate(instanceID string, public bool) (json *gabs.Container, err error) {
	params := ""
	if public {
		params = "public=true"
	}
	return makeJSONCall(config.URL()+"/v1/instances/"+instanceID+"/ip", HTTPPost, params)
}
예제 #6
0
func AccountFindByToken(token string) string {
	accounts, err := makeJSONCall(config.URL()+"/v1/accounts", HTTPGet, "")
	if err != nil {
		fmt.Println(err)
		return ""
	}

	items, _ := accounts.Children()
	for _, child := range items {
		if child.S("api_key").Data().(string) == token {
			return child.S("username").Data().(string)
		}
	}
	return ""
}
예제 #7
0
func InstanceDestroy(id string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/instances/"+id, HTTPDelete, "")
}
예제 #8
0
func AccountDelete(name string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/accounts/"+name, HTTPDelete, "")
}
예제 #9
0
func AccountReset(name string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/accounts/"+name, HTTPPut, fmt.Sprintf("name=%s", name))
}
예제 #10
0
func RegionsList() (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/regions", HTTPGet, "")
}
예제 #11
0
func AccountCreate(name string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/accounts", HTTPPost, fmt.Sprintf("name=%s", name))
}
예제 #12
0
func FirewallRuleDelete(name, id string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/firewalls/"+name+"/rules/"+id, HTTPDelete, "")
}
예제 #13
0
func SshKeyCreate(params SshKeyParams) (json *gabs.Container, err error) {
	v, _ := query.Values(params)
	return makeJSONCall(config.URL()+"/v1/sshkeys", HTTPPost, v.Encode())
}
예제 #14
0
func FirewallCreate(name string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/firewalls", HTTPPost, "name="+name)
}
예제 #15
0
func FirewallRules(name string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/firewalls/"+name+"/rules", HTTPGet, "")
}
예제 #16
0
func AccountsList() (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/accounts", HTTPGet, "")
}
예제 #17
0
func SnapshotsList() (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/snapshots", HTTPGet, "")
}
예제 #18
0
func InstanceCreate(params InstanceParams) (json *gabs.Container, err error) {
	v, _ := query.Values(params)
	return makeJSONCall(config.URL()+"/v1/instances", HTTPPost, v.Encode())
}
예제 #19
0
func SnapshotDestroy(id string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/snapshots/"+id, HTTPDelete, "")
}
예제 #20
0
func QuotaSet(params QuotaParams) (json *gabs.Container, err error) {
	v, _ := query.Values(params)
	return makeJSONCall(config.URL()+"/v1/quota/"+params.Account, HTTPPut, v.Encode())
}
예제 #21
0
func FirewallsList() (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/firewalls", HTTPGet, "")
}
예제 #22
0
func InstanceRestore(id, snapshot string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/instances/"+id+"/restore", HTTPPut, "snapshot="+snapshot)
}
예제 #23
0
func FirewallDestroy(name string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/firewalls/"+name, HTTPDelete, "")
}
예제 #24
0
func InstanceRebuild(id string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/instances/"+id+"/rebuild", HTTPPut, "")
}
예제 #25
0
func FirewallRuleCreate(name string, params FirewallRuleParams) (json *gabs.Container, err error) {
	v, _ := query.Values(params)
	return makeJSONCall(config.URL()+"/v1/firewalls/"+name+"/rules", HTTPPost, v.Encode())
}
예제 #26
0
func InstanceFirewall(id, firewall string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/instances/"+id+"/firewall", HTTPPut, "name="+firewall)
}
예제 #27
0
func SshKeysList() (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/sshkeys", HTTPGet, "")
}
예제 #28
0
func InstanceTags(id, tags string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/instances/"+id+"/tags", HTTPPut, "tags="+tags)
}
예제 #29
0
func SshKeyDelete(name string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/sshkeys/"+name, HTTPDelete, "")
}
예제 #30
0
func InstanceUpgrade(id, size string) (json *gabs.Container, err error) {
	return makeJSONCall(config.URL()+"/v1/instances/"+id, HTTPPut, "size="+size)
}