Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize value 0 for int #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rensvanleeuwen
Copy link

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 rensvanleeuwen force-pushed the delayaction-serialization branch from da1c1b8 to 64c7ed1 Compare April 9, 2020 10:09
@rensvanleeuwen
Copy link
Author

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant