opsgenie / opsgenie-go-sdk-v2

Opsgenie GO SDK v2
Apache License 2.0
34 stars 63 forks source link

Serialize value 0 for int #40

Open rensvanleeuwen opened 4 years ago

rensvanleeuwen commented 4 years ago

DISCLAIMER: I a Golang and an open source beginner. Please bear with me.

I ran into an issue when I was copying policies from one Opsgenie account to the other. I was reading the following policy:

{
    "type": "notification",
    "name": "Delay business-hours tag till the next business day",
    "enabled": false,
    "policyDescription": "",
    "filter": {
        "type": "match-any-condition",
        "conditions": [{
            "field": "tags",
            "not": false,
            "operation": "contains",
            "expectedValue": "business-hours",
            "order": 0
        }]
    },
    "timeRestrictions": {
        "type": "weekday-and-time-of-day",
        "restrictions": [{
            "startDay": "monday",
            "startHour": 17,
            "startMin": 0,
            "endHour": 8,
            "endDay": "tuesday",
            "endMin": 0
        }, {
            "startDay": "tuesday",
            "startHour": 17,
            "startMin": 0,
            "endHour": 8,
            "endDay": "wednesday",
            "endMin": 0
        }, {
            "startDay": "wednesday",
            "startHour": 17,
            "startMin": 0,
            "endHour": 8,
            "endDay": "thursday",
            "endMin": 0
        }, {
            "startDay": "thursday",
            "startHour": 17,
            "startMin": 0,
            "endHour": 8,
            "endDay": "friday",
            "endMin": 0
        }, {
            "startDay": "friday",
            "startHour": 17,
            "startMin": 0,
            "endHour": 8,
            "endDay": "monday",
            "endMin": 0
        }],
        "restriction": {}
    },
    "TeamId": "288b503a-6d04-4bae-9761-d1c9fd725ad7",
    "delayAction": {
        "delayOption": "next-weekday",
        "untilMinute": 0,
        "untilHour": 10
    },
    "suppress": false
}

and then copied state to a CreateNotificationPolicyRequest to create it on the other Opsgenie account. I was getting back an HTTP 422 with the message delayAction's UntilHour or UntilMinute is not valid.

I turns out that "untilMinute": 0, when serialized is being omitted from the request, as the property UntilMinute holds the default int value. I needs to be changed to a pointer to an int instead.

rensvanleeuwen commented 4 years ago

@cemkucuk @faziletozer Sorry to bother you, but since you two got the latest PR merged ..

What is the process to have a PR looked into by someone familiar with the code base and permissions to merge it?