Open vthiery opened 3 years ago
You can use implementation similar to createRuleStep func to execute the above use case.
func NewNotifiactionClient() (*notification.Client, error) {
config := client.Config{
ApiKey: "******",
OpsGenieAPIURL: client.ApiUrl("*******"),
}
var alertCli, cliErr = notification.NewClient(&config)
if cliErr != nil {
message := "Can not create the alert client. " + cliErr.Error()
return nil, errors.New(message)
}
return alertCli, nil
}
func createRuleStep() {
var cli, _ = NewNotifiactionClient()
var createRequest = notification.CreateRuleStepRequest{}
createRequest.UserIdentifier = "123"
createRequest.RuleId = "123"
createRequest.Contact.To = "ab@email.com"
createRequest.Contact.MethodOfContact = og.Email
b := true
createRequest.Enabled = &b
timeAmount := uint32(0)
sendAfter := og.SendAfter{TimeAmount: &timeAmount, TimeUnit: "minutes"}
createRequest.SendAfter = &sendAfter
response, _ := cli.CreateRuleStep(nil, &createRequest)
fmt.Printf("%+v\n", response)
}
Any news on this? It's a one-line fix. (trabab's proposed workaround is not valid - cannot possibly compile - since TimeAmount is not a pointer.)
I want to define a notification rule step for a "New Alert" with no delay (so that I immediately receive the notification). The Opsgenie API documentation indicates that the
sendAfter
field must be specified for New Alert and Assigned Alert notification rules:Nevertheless, specifying
0
asTimeAmount
won't work because the field would be omitted:On the other hand, the API is perfectly happy to receive
0
.Would simply removing
omitempty
be a viable solution?