// DisableAction disables an integration/policy according to the --type parameter at OpsGenie. func DisableAction(c *gcli.Context) { val, _ := getVal("type", c) switch val { case "policy": cli, err := NewPolicyClient(c) if err != nil { os.Exit(1) } req := policy.DisablePolicyRequest{} if val, success := getVal("id", c); success { req.ID = val } if val, success := getVal("name", c); success { req.Name = val } printVerboseMessage("Disable policy request prepared from flags, sending request to OpsGenie..") _, err = cli.Disable(req) if err != nil { fmt.Printf("%s\n", err.Error()) os.Exit(1) } fmt.Printf("Policy disabled successfuly\n") case "integration": cli, err := NewIntegrationClient(c) if err != nil { os.Exit(1) } req := integration.DisableIntegrationRequest{} if val, success := getVal("id", c); success { req.ID = val } if val, success := getVal("name", c); success { req.Name = val } printVerboseMessage("Disable integration request prepared from flags, sending request to OpsGenie..") _, err = cli.Disable(req) if err != nil { fmt.Printf("%s\n", err.Error()) os.Exit(1) } fmt.Printf("Integration disabled successfuly\n") default: fmt.Printf("Invalid type option %s, specify either integration or policy\n", val) gcli.ShowCommandHelp(c, "disable") os.Exit(1) } }