// EnableAction enables an integration/policy according to the --type parameter at OpsGenie.
func EnableAction(c *gcli.Context) {
	val, _ := getVal("type", c)
	switch val {
	case "policy":
		cli, err := NewPolicyClient(c)
		if err != nil {
			os.Exit(1)
		}

		req := policy.EnablePolicyRequest{}
		if val, success := getVal("id", c); success {
			req.ID = val
		}
		if val, success := getVal("name", c); success {
			req.Name = val
		}
		printVerboseMessage("Enable policy request prepared from flags, sending request to OpsGenie..")
		_, err = cli.Enable(req)
		if err != nil {
			fmt.Printf("%s\n", err.Error())
			os.Exit(1)
		}
		fmt.Printf("Policy enabled successfuly\n")

	case "integration":
		cli, err := NewIntegrationClient(c)
		if err != nil {
			os.Exit(1)
		}

		req := integration.EnableIntegrationRequest{}
		if val, success := getVal("id", c); success {
			req.ID = val
		}
		if val, success := getVal("name", c); success {
			req.Name = val
		}
		printVerboseMessage("Enable integration request prepared from flags, sending request to OpsGenie..")
		_, err = cli.Enable(req)
		if err != nil {
			fmt.Printf("%s\n", err.Error())
			os.Exit(1)
		}
		fmt.Printf("Integration enabled successfuly\n")
	default:
		fmt.Printf("Invalid type option %s, specify either integration or policy\n", val)
		gcli.ShowCommandHelp(c, "enable")
		os.Exit(1)
	}
}