func cmdUpdateTemplateScript(c *cli.Context) { utils.FlagsRequired(c, []string{"id", "template_id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) v := make(map[string]interface{}) if c.IsSet("parameter_values") { var params TemplateScriptCredentials err = json.Unmarshal([]byte(c.String("credentials")), ¶ms) v["parameter_values"] = params } jsonBytes, err := json.Marshal(v) utils.CheckError(err) err, res, code := webservice.Put(fmt.Sprintf("/v1/blueprint/templates/%s/scripts/%s", c.String("template_id"), c.String("id")), jsonBytes) utils.CheckError(err) utils.CheckReturnCode(code, res) var templateScript TemplateScript err = json.Unmarshal(res, &templateScript) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tTYPE\tEXECUTION ORDER\tTEMPLATE ID\tSCRIPT ID\tPARAMETER VALUES\r") fmt.Fprintf(w, "%s\t%s\t%d\t%s\t%s\t%s\n", templateScript.Id, templateScript.Type, templateScript.Execution_Order, templateScript.Template_Id, templateScript.Script_Id, templateScript.Parameter_Values) w.Flush() }
func cmdAdd(c *cli.Context) { utils.FlagsRequired(c, []string{"cidr", "minPort", "maxPort", "ipProtocol"}) // API accepts only 1 rule newRule := &Rule{ c.String("ipProtocol"), c.String("cidr"), c.Int("minPort"), c.Int("maxPort"), } policy := get() exists := check(policy, *newRule) if exists == false { policy.Rules = append(policy.Rules, *newRule) webservice, err := webservice.NewWebService() utils.CheckError(err) nRule := make(map[string]Rule) nRule["rule"] = *newRule json, err := json.Marshal(nRule) utils.CheckError(err) err, res, code := webservice.Post(fmt.Sprintf("%s/rules", endpoint), json) if res == nil { log.Fatal(err) } utils.CheckError(err) utils.CheckReturnCode(code, res) } }
func cmdUpdate(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) v := make(map[string]string) if c.IsSet("name") { v["name"] = c.String("name") } if c.IsSet("public_key") { v["public_key"] = c.String("public_key") } if c.IsSet("private_key") { v["private_key"] = c.String("private_key") } jsonBytes, err := json.Marshal(v) utils.CheckError(err) err, res, code := webservice.Put(fmt.Sprintf("/v1/cloud/ssh_profiles/%s", c.String("id")), jsonBytes) utils.CheckError(err) utils.CheckReturnCode(code, res) var sshProfile SSHProfile err = json.Unmarshal(res, &sshProfile) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\rPUBLIC KEY\tPRIVATE KEY\r") fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", sshProfile.Id, sshProfile.Name, sshProfile.Public_key, sshProfile.Private_key) w.Flush() }
func cmdCreate(c *cli.Context) { utils.FlagsRequired(c, []string{"saas_provider_id", "account_data"}) webservice, err := webservice.NewWebService() utils.CheckError(err) credentialsString := []byte(c.String("account_data")) var jsonCredentials SaasRequiredCredentials err = json.Unmarshal(credentialsString, &jsonCredentials) v := make(map[string]interface{}) v["saas_provider_id"] = c.String("saas_provider_id") v["account_data"] = jsonCredentials jsonBytes, err := json.Marshal(v) utils.CheckError(err) err, res, code := webservice.Post("/v1/settings/saas_accounts", jsonBytes) if res == nil { log.Fatal(err) } utils.CheckError(err) utils.CheckReturnCode(code, res) }
func cmdCreate(c *cli.Context) { utils.FlagsRequired(c, []string{"name", "description", "code"}) webservice, err := webservice.NewWebService() utils.CheckError(err) v := make(map[string]string) v["name"] = c.String("name") v["description"] = c.String("description") v["code"] = c.String("code") if c.IsSet("parameters") { v["parameters"] = c.String("parameters") } jsonBytes, err := json.Marshal(v) utils.CheckError(err) err, res, code := webservice.Post("/v1/blueprint/scripts", jsonBytes) if res == nil { log.Fatal(err) } utils.CheckError(err) utils.CheckReturnCode(code, res) var new_script Script err = json.Unmarshal(res, &new_script) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tDESCRIPTION\tCODE\tPARAMETERS\r") fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", new_script.Id, new_script.Name, new_script.Description, new_script.Code, new_script.Parameters) w.Flush() }
func cmdUpdate(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) v := make(map[string]string) if c.IsSet("name") { v["name"] = c.String("name") } if c.IsSet("fqdn") { v["fqdn"] = c.String("fqdn") } jsonBytes, err := json.Marshal(v) utils.CheckError(err) err, res, code := webservice.Put(fmt.Sprintf("/v1/cloud/servers/%s", c.String("id")), jsonBytes) utils.CheckError(err) utils.CheckReturnCode(code, res) var server Server err = json.Unmarshal(res, &server) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tFQDN\tSTATE\tPUBLIC IP\tWORKSPACE ID\tTEMPLATE ID\tSERVER PLAN ID\tSSH PROFILE ID\r") fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", server.Id, server.Name, server.Fqdn, server.State, server.Public_ip, server.Workspace_id, server.Template_id, server.Server_plan_id, server.Ssh_profile_id) w.Flush() }
func cmdShow(c *cli.Context) { var vals LicenseeReport utils.FlagsRequired(c, []string{"id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) err, data, res := webservice.Get(fmt.Sprintf("/v1/licensee/reports/%s", c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, data) err = json.Unmarshal(data, &vals) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "REPORT ID\tYEAR\tMONTH\tSTART TIME\tEND TIME\tSERVER SECONDS\tCLOSED\r") fmt.Fprintf(w, "%s\t%d\t%s\t%s\t%s\t%g\t%t\n", vals.Id, vals.Year, vals.Month, vals.StartTime, vals.EndTime, vals.ServerSeconds, vals.Closed) fmt.Fprintln(w, "LINES:\r") fmt.Fprintln(w, "ID\tCOMMISSIONED AT\tDECOMMISSIONED AT\tINSTANCE ID\tINSTANCE NAME\tINSTANCE FQDN\tCONSUMPTION\r") for _, l := range vals.Li { fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%g\n", l.Id, l.Commissioned_at, l.Decommissioned_at, l.Instance_id, l.Instance_name, l.Instance_fqdn, l.Consumption) } w.Flush() }
func cmdAddNode(c *cli.Context) { utils.FlagsRequired(c, []string{"balancer_id", "server_id", "port"}) webservice, err := webservice.NewWebService() utils.CheckError(err) v := make(map[string]string) v["server_id"] = c.String("server_id") v["port"] = c.String("port") jsonBytes, err := json.Marshal(v) utils.CheckError(err) err, res, code := webservice.Post(fmt.Sprintf("/v1/network/load_balancers/%s/nodes", c.String("balancer_id")), jsonBytes) if res == nil { log.Fatal(err) } utils.CheckError(err) utils.CheckReturnCode(code, res) var n Node err = json.Unmarshal(res, &n) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tPUBLIC IP\tSTATE\tSERVER ID\tPORT\r") fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%d\n", n.Id, n.Name, n.PublicIp, n.State, n.ServerId, n.Port) w.Flush() }
func cmdCreate(c *cli.Context) { utils.FlagsRequired(c, []string{"name", "domain_id", "ssh_profile_id", "firewall_profile_id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) v := make(map[string]string) v["name"] = c.String("name") v["domain_id"] = c.String("domain_id") v["ssh_profile_id"] = c.String("ssh_profile_id") v["firewall_profile_id"] = c.String("firewall_profile_id") jsonBytes, err := json.Marshal(v) utils.CheckError(err) err, res, code := webservice.Post("/v1/cloud/workspaces", jsonBytes) if res == nil { log.Fatal(err) } utils.CheckError(err) utils.CheckReturnCode(code, res) var workspace Workspace err = json.Unmarshal(res, &workspace) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tDEFAULT\tDOMAIN ID\tSSH PROFILE ID\tFIREWALL PROFILE ID\r") fmt.Fprintf(w, "%s\t%s\t%t\t%s\t%s\t%s\n", workspace.Id, workspace.Name, workspace.Default, workspace.Domain_id, workspace.Ssh_profile_id, workspace.Firewall_profile_id) w.Flush() }
func cmdReorderTemplateScripts(c *cli.Context) { utils.FlagsRequired(c, []string{"template_id", "type", "script_ids"}) webservice, err := webservice.NewWebService() utils.CheckError(err) v := make(map[string]interface{}) v["type"] = c.String("type") v["script_ids"] = c.GlobalStringSlice("script_ids") jsonBytes, err := json.Marshal(v) utils.CheckError(err) err, res, code := webservice.Put(fmt.Sprintf("/v1/blueprint/templates/%s/scripts/reorder", c.String("template_id")), jsonBytes) utils.CheckError(err) utils.CheckReturnCode(code, res) var templateScripts []TemplateScript err = json.Unmarshal(res, &templateScripts) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tTYPE\tEXECUTION ORDER\tTEMPLATE ID\tSCRIPT ID\tPARAMETER VALUES\r") for _, templateScript := range templateScripts { fmt.Fprintf(w, "%s\t%s\t%d\t%s\t%s\t%s\n", templateScript.Id, templateScript.Type, templateScript.Execution_Order, templateScript.Template_Id, templateScript.Script_Id, templateScript.Parameter_Values) } w.Flush() }
func cmdDeleteTemplateScript(c *cli.Context) { utils.FlagsRequired(c, []string{"id", "template_id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) err, mesg, res := webservice.Delete(fmt.Sprintf("/v1/blueprint/templates/%s/scripts/%s", c.String("template_id"), c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, mesg) }
func cmdDelete(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) err, mesg, res := webservice.Delete(fmt.Sprintf("/v1/cloud/workspaces/%s", c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, mesg) }
func cmdDeleteDomainRecords(c *cli.Context) { utils.FlagsRequired(c, []string{"domain_id", "id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) err, mesg, res := webservice.Delete(fmt.Sprintf("/v1/dns/domains/%s/records/%s", c.String("domain_id"), c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, mesg) }
func cmdDelNode(c *cli.Context) { utils.FlagsRequired(c, []string{"balancer_id", "node_id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) err, mesg, res := webservice.Delete(fmt.Sprintf("/v1/network/load_balancers/%s/nodes/%s", c.String("balancer_id"), c.String("node_id"))) utils.CheckError(err) utils.CheckReturnCode(res, mesg) }
func cmdCreate(c *cli.Context) { utils.FlagsRequired(c, []string{"protocol"}) if c.String("protocol") == "https" { utils.FlagsRequired(c, []string{"name", "fqdn", "protocol", "domain_id", "cloud_provider_id", "ssl_certificate", "ssl_certificate_private_key"}) } else { utils.FlagsRequired(c, []string{"name", "fqdn", "protocol", "domain_id", "cloud_provider_id"}) } webservice, err := webservice.NewWebService() utils.CheckError(err) v := make(map[string]string) v["name"] = c.String("name") v["fqdn"] = c.String("fqdn") v["protocol"] = strings.ToLower(c.String("protocol")) v["domain_id"] = c.String("domain_id") v["cloud_provider_id"] = c.String("cloud_provider_id") if c.IsSet("ssl_certificate") { v["ssl_certificate"] = c.String("ssl_certificate") } if c.IsSet("ssl_certificate_private_key") { v["ssl_certificate_private_key"] = c.String("ssl_certificate_private_key") } if c.IsSet("port") { v["port"] = c.String("port") } if c.IsSet("algorithm") { v["algorithm"] = c.String("algorithm") } jsonBytes, err := json.Marshal(v) utils.CheckError(err) err, res, code := webservice.Post("/v1/network/load_balancers", jsonBytes) if res == nil { log.Fatal(err) } utils.CheckError(err) utils.CheckReturnCode(code, res) var lb LoadBalancer err = json.Unmarshal(res, &lb) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tFQDN\tPROTOCOL\tPORT\tALGORITHM\tSSL CERTIFICATE\tSSL CERTIFICATE PRIVATE KEY\tDOMAIN ID\tCLOUD PROVIDER ID\tTRAFFIC IN\tTRAFFIC OUT\r") fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\t%s\t%s\t%s\t%s\t%s\t%d\t%d\n", lb.Id, lb.Name, lb.Fqdn, lb.Protocol, lb.Port, lb.Algorithm, lb.SslCertificate, lb.Ssl_certificate_private_key, lb.Domain_id, lb.Cloud_provider_id, lb.Traffic_in, lb.Traffic_out) w.Flush() }
func cmdList(c *cli.Context) { var accounts []Account webservice, err := webservice.NewWebService() utils.CheckError(err) err, data, res := webservice.Get("/v1/settings/cloud_accounts") utils.CheckError(err) utils.CheckReturnCode(res, data) err = json.Unmarshal(data, &accounts) utils.CheckError(err) err, data, res = webservice.Get("/v1/cloud/cloud_providers") utils.CheckError(err) utils.CheckReturnCode(res, data) var cloudProviders []providers.CloudProvider err = json.Unmarshal(data, &cloudProviders) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tCLOUD PROVIDER ID\tNAME\r") for _, ac := range accounts { acName := "" for _, cp := range cloudProviders { if ac.CloudProvId == cp.Id { acName = cp.Name break } } fmt.Fprintf(w, "%s\t%s\t%s\n", ac.Id, ac.CloudProvId, acName) } w.Flush() }
func cmdUpdate(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) fp := FirewallProfile{ Id: c.String("id"), } if c.IsSet("name") { fp.Name = c.String("name") } if c.IsSet("description") { fp.Description = c.String("description") } if c.IsSet("rules") { var rules []Rule err = json.Unmarshal([]byte(c.String("rules")), &rules) utils.CheckError(err) fp.Rules = rules } jsonBytes, err := json.Marshal(fp) utils.CheckError(err) err, res, code := webservice.Put(fmt.Sprintf("/v1/network/firewall_profiles/%s", c.String("id")), jsonBytes) utils.CheckError(err) utils.CheckReturnCode(code, res) var firewallProfile FirewallProfile err = json.Unmarshal(res, &firewallProfile) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tDESCRIPTION\tDEFAULT\r") fmt.Fprintf(w, "%s\t%s\t%s\t%t\n", firewallProfile.Id, firewallProfile.Name, firewallProfile.Description, firewallProfile.Default) fmt.Fprintln(w, "RULES:\r") fmt.Fprintln(w, "\tPROTOCOL\tMIN PORT\tMAX PORT\tSOURCE\r") for _, r := range firewallProfile.Rules { fmt.Fprintf(w, "\t%s\t%d\t%d\t%s\n", r.Protocol, r.MinPort, r.MaxPort, r.CidrIp) } w.Flush() }
func cmdUpdate(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) template := Template{ Id: c.String("id"), } if c.IsSet("name") { template.Name = c.String("name") } if c.IsSet("service_list") { var services []string err = json.Unmarshal([]byte(c.String("service_list")), &services) utils.CheckError(err) template.ServiceList = services } if c.IsSet("configuration_attributes") { attributes := []byte(c.String("configuration_attributes")) attributesAddress := (*json.RawMessage)(&attributes) template.ConfigurationAttributes = attributesAddress utils.CheckError(err) } jsonBytes, err := json.Marshal(template) utils.CheckError(err) err, res, code := webservice.Put(fmt.Sprintf("/v1/blueprint/templates/%s", c.String("id")), jsonBytes) utils.CheckReturnCode(code, res) utils.CheckError(err) err = json.Unmarshal(res, &template) utils.CheckError(err) serviceList, err := json.Marshal(template.ServiceList) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tGENERIC IMAGE ID\tSERVICE LIST\tCONFIGURATION ATTRIBUTES\r") fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", template.Id, template.Name, template.GenericImgId, serviceList, *template.ConfigurationAttributes) w.Flush() }
func cmdExecuteScript(c *cli.Context) { utils.FlagsRequired(c, []string{"server_id", "script_id"}) webservice, err := webservice.NewWebService() utils.CheckError(err) err, res, code := webservice.Put(fmt.Sprintf("/v1/cloud/servers/%s/operational_scripts/%s/execute", c.String("server_id"), c.String("script_id")), nil) utils.CheckError(err) utils.CheckReturnCode(code, res) var event Event err = json.Unmarshal(res, &event) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tTIMESTAMP\tLEVEL\tHEADER\tDESCRIPTION\r") fmt.Fprintf(w, "%s\t%s\t%t\t%s\t%t\n", event.Id, event.Timestamp, event.Level, event.Header, event.Description) w.Flush() }
func cmdShow(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) var sshProfile SSHProfile webservice, err := webservice.NewWebService() utils.CheckError(err) err, data, res := webservice.Get(fmt.Sprintf("/v1/cloud/ssh_profiles/%s", c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, data) err = json.Unmarshal(data, &sshProfile) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\rPUBLIC KEY\tPRIVATE KEY\r") fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", sshProfile.Id, sshProfile.Name, sshProfile.Public_key, sshProfile.Private_key) w.Flush() }
func cmdShow(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) var sp ServerPlan webservice, err := webservice.NewWebService() utils.CheckError(err) err, data, res := webservice.Get(fmt.Sprintf("/v1/cloud/server_plans/%s", c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, data) err = json.Unmarshal(data, &sp) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tMEMORY\tCPUS\tSTORAGE\tLOCATION ID\tCLOUD PROVIDER ID\r") fmt.Fprintf(w, "%s\t%s\t%d\t%g\t%d\t%s\t%s\n", sp.Id, sp.Name, sp.Memory, sp.CPUs, sp.Storage, sp.LocationId, sp.CloudProviderId) w.Flush() }
func cmdShow(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) var workspace Workspace webservice, err := webservice.NewWebService() utils.CheckError(err) err, data, res := webservice.Get(fmt.Sprintf("/v1/cloud/workspaces/%s", c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, data) err = json.Unmarshal(data, &workspace) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tDEFAULT\tDOMAIN ID\tSSH PROFILE ID\tFIREWALL PROFILE ID\r") fmt.Fprintf(w, "%s\t%s\t%t\t%s\t%s\t%s\n", workspace.Id, workspace.Name, workspace.Default, workspace.Domain_id, workspace.Ssh_profile_id, workspace.Firewall_profile_id) w.Flush() }
func cmdShow(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) var server Server webservice, err := webservice.NewWebService() utils.CheckError(err) err, data, res := webservice.Get(fmt.Sprintf("/v1/cloud/servers/%s", c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, data) err = json.Unmarshal(data, &server) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tFQDN\tSTATE\tPUBLIC IP\tWORKSPACE ID\tTEMPLATE ID\tSERVER PLAN ID\tSSH PROFILE ID\r") fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", server.Id, server.Name, server.Fqdn, server.State, server.Public_ip, server.Workspace_id, server.Template_id, server.Server_plan_id, server.Ssh_profile_id) w.Flush() }
func cmdShowDomainRecords(c *cli.Context) { utils.FlagsRequired(c, []string{"domain_id", "id"}) var dr DomainRecord webservice, err := webservice.NewWebService() utils.CheckError(err) err, data, res := webservice.Get(fmt.Sprintf("/v1/dns/domains/%s/records/%s", c.String("domain_id"), c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, data) err = json.Unmarshal(data, &dr) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tTYPE\tNAME\tCONTENT\tTTL\tPRIORITY\tSERVER ID\tDOMAIN ID\r") fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\t%d\t%s\t%s\n", dr.Id, dr.Type, dr.Name, dr.Content, dr.Ttl, dr.Prio, dr.Server_id, dr.Domain_id) w.Flush() }
func cmdShow(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) var script Script webservice, err := webservice.NewWebService() utils.CheckError(err) err, data, res := webservice.Get(fmt.Sprintf("/v1/blueprint/scripts/%s", c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, data) err = json.Unmarshal(data, &script) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tDESCRIPTION\tCODE\tPARAMETERS\r") fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", script.Id, script.Name, script.Description, script.Code, script.Parameters) w.Flush() }
func cmdShowTemplateScript(c *cli.Context) { utils.FlagsRequired(c, []string{"id", "template_id"}) var templateScript TemplateScript webservice, err := webservice.NewWebService() utils.CheckError(err) err, data, res := webservice.Get(fmt.Sprintf("/v1/blueprint/templates/%s/scripts/%s", c.String("template_id"), c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, data) err = json.Unmarshal(data, &templateScript) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tTYPE\tEXECUTION ORDER\tTEMPLATE ID\tSCRIPT ID\tPARAMETER VALUES\r") fmt.Fprintf(w, "%s\t%s\t%d\t%s\t%s\t%s\n", templateScript.Id, templateScript.Type, templateScript.Execution_Order, templateScript.Template_Id, templateScript.Script_Id, templateScript.Parameter_Values) w.Flush() }
func cmdShow(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) var service Service webservice, err := webservice.NewWebService() utils.CheckError(err) err, data, res := webservice.Get(fmt.Sprintf("/v1/blueprint/services/%s", c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, data) err = json.Unmarshal(data, &service) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tDESCRIPTION\tPUBLIC\tLICENSE\tRECIPES\r") fmt.Fprintf(w, "%s\t%s\t%s\t%t\t%s\t%s\n", service.Id, service.Name, service.Description, service.Public, service.License, service.Recipes) w.Flush() }
func cmdShow(c *cli.Context) { utils.FlagsRequired(c, []string{"id"}) var lb LoadBalancer webservice, err := webservice.NewWebService() utils.CheckError(err) err, data, res := webservice.Get(fmt.Sprintf("/v1/network/load_balancers/%s", c.String("id"))) utils.CheckError(err) utils.CheckReturnCode(res, data) err = json.Unmarshal(data, &lb) utils.CheckError(err) w := tabwriter.NewWriter(os.Stdout, 15, 1, 3, ' ', 0) fmt.Fprintln(w, "ID\tNAME\tFQDN\tPROTOCOL\tPORT\tALGORITHM\tSSL CERTIFICATE\tSSL CERTIFICATE PRIVATE KEY\tDOMAIN ID\tCLOUD PROVIDER ID\tTRAFFIC IN\tTRAFFIC OUT\r") fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\t%s\t%s\t%s\t%s\t%s\t%d\t%d\n", lb.Id, lb.Name, lb.Fqdn, lb.Protocol, lb.Port, lb.Algorithm, lb.SslCertificate, lb.Ssl_certificate_private_key, lb.Domain_id, lb.Cloud_provider_id, lb.Traffic_in, lb.Traffic_out) w.Flush() }
func cmdCreate(c *cli.Context) { utils.FlagsRequired(c, []string{"cluster", "plan"}) webservice, err := webservice.NewWebService() utils.CheckError(err) v := make(map[string]string) v["fleet_name"] = c.String("cluster") v["plan"] = c.String("plan") json, err := json.Marshal(v) utils.CheckError(err) err, res, code := webservice.Post("/v1/kaas/ships", json) if res == nil { log.Fatal(err) } utils.CheckError(err) utils.CheckReturnCode(code, res) }
func cmdCreate(c *cli.Context) { utils.FlagsRequired(c, []string{"cluster"}) webservice, err := webservice.NewWebService() utils.CheckError(err) v := make(map[string]string) v["name"] = c.String("cluster") if c.IsSet("domain_id") { v["domain_id"] = c.String("domain_id") } json, err := json.Marshal(v) utils.CheckError(err) err, mesg, code := webservice.Post("/v1/kaas/fleets", json) utils.CheckError(err) utils.CheckReturnCode(code, mesg) }