-
Notifications
You must be signed in to change notification settings - Fork 213
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
docs: clarify service event rules time frame parameters #391
Conversation
Usage of `Unix timestamp` here is confusing, as it means _the number of (milli-)seconds that have elapsed since the Unix Epoch (January 1st, 1970 at UTC). Note that official API docs do not mention Unix: ``` "time_frame": { "description": "Time-based conditions for limiting when the rule is active.", "type": "object", "properties": { "active_between": { "type": "object", "required": [ "start_time", "end_time" ], "description": "A fixed window of time during which the rule is active.", "properties": { "start_time": { "type": "integer", "description": "The start time in milliseconds." }, "end_time": { "type": "integer", "description": "End time in milliseconds." } } }, "scheduled_weekly": { "type": "object", "required": [ "start_time", "duration", "timezone", "weekdays" ], "description": "A reccuring window of time based on the day of the week, during which the rule is active.", "properties": { "start_time": { "type": "integer", "description": "The amount of milliseconds into the day at which the window starts." }, "duration": { "type": "integer", "description": "The duration of the window in milliseconds." }, "timezone": { "type": "string", "description": "The timezone." }, "weekdays": { "type": "array", "description": "An array of day values. Ex [1, 3, 5] is Monday, Wednesday, Friday.", "items": { "type": "integer" } } } } } }, ``` https://github.com/PagerDuty/api-schema/blob/main/reference/REST/openapiv3.json https://developer.pagerduty.com/api-reference/reference/REST/openapiv3.json/paths/~1services~1%7Bid%7D~1rules/post
@@ -136,11 +136,11 @@ The following arguments are supported: | |||
* `scheduled_weekly` (Optional) - Values for executing the rule on a recurring schedule. | |||
* `weekdays` - An integer array representing which days during the week the rule executes. For example `weekdays = [1,3,7]` would execute on Monday, Wednesday and Sunday. | |||
* `timezone` - Timezone for the given schedule. | |||
* `start_time` - Time when the schedule will start. Unix timestamp in milliseconds. For example, if you have a rule with a `start_time` of `0` and a `duration` of `60,000` then that rule would be active from `00:00` to `00:01`. If the `start_time` was `3,600,000` the it would be active starting at `01:00`. | |||
* `duration` - Length of time the schedule will be active. Unix timestamp in milliseconds. | |||
* `start_time` - Time when the schedule will start. Timestamp in milliseconds relative to the beginning of the day. For example, if you have a rule with a `start_time` of `0` and a `duration` of `60,000` then that rule would be active from `00:00` to `00:01`. If the `start_time` was `3,600,000` the it would be active starting at `01:00`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also say time
instead of timestamp
(which by itself is also meant to be absolute) like in official API documentation:
* `start_time` - Time when the schedule will start. Timestamp in milliseconds relative to the beginning of the day. For example, if you have a rule with a `start_time` of `0` and a `duration` of `60,000` then that rule would be active from `00:00` to `00:01`. If the `start_time` was `3,600,000` the it would be active starting at `01:00`. | |
* `start_time` - Time when the schedule will start. Time in milliseconds relative to the beginning of the day. For example, if you have a rule with a `start_time` of `0` and a `duration` of `60,000` then that rule would be active from `00:00` to `00:01`. If the `start_time` was `3,600,000` the it would be active starting at `01:00`. |
* `start_time` - Beginning of the scheduled time when the rule should execute. Timestamp in milliseconds relative to the beginning of the day. | ||
* `end_time` - Ending of the scheduled time when the rule should execute. Timestamp in milliseconds relative to the beginning of the day. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also say time
instead of timestamp
(which by itself is also meant to be absolute) like in official API documentation:
* `start_time` - Beginning of the scheduled time when the rule should execute. Timestamp in milliseconds relative to the beginning of the day. | |
* `end_time` - Ending of the scheduled time when the rule should execute. Timestamp in milliseconds relative to the beginning of the day. | |
* `start_time` - Beginning of the scheduled time when the rule should execute. Time in milliseconds relative to the beginning of the day. | |
* `end_time` - Ending of the scheduled time when the rule should execute. Time in milliseconds relative to the beginning of the day. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ha! I didn't realize that there were multiple spots in the terraform docs where we describe an event rule's start_at
value! I'd previously clarified the wording of this portion of the API here: #340
I feel very strongly that we should adjust the wording & code samples on this page to match the wording & code samples on ruleset_rule.html.markdown
page to help our customers avoid bugs. For example: https://github.com/metavida/terraform-provider-pagerduty/blob/e3f0ec6f1dc89847061d18c7e874e77b90cd7dc3/website/docs/r/ruleset_rule.html.markdown?plain=1#L148-L150
Let me know if you've got any questions.
So you are saying these are actual Unix timestamps, and it's the official API reference that needs clarification? https://github.com/PagerDuty/api-schema/blob/main/reference/REST/openapiv3.json |
Yes, I can confirm that the You can observe this, in practice, by fetching the schedule of an event rule that you create in the UI. Here's a rule with a recurring schedule that created just now via the UI: And here's what the API response for that rule looks like:
So the UI set the the I don't know the history of how this API's structure came to be, but my guess is that it's a case where the customer-facing API ended up exposing the UI implementation and/or storage implementation details a bit more directly than is helpful. Next stepsWhat your preferred path forward?
I've already opened up a ticket to get the REST API docs updated appropriately (because I don't think docs can accept an open-source PR). Last, but not least, thanks for opening this PR & raising all these documentation inconsistencies! |
Thanks, I'll update the documentation accordingly in this PR. In the meantime, I've marked it as draft to prevent it from being merged as is. |
Usage of
Unix timestamp
here is confusing, as that usually means the number of (milli-)seconds that have elapsed since the Unix Epoch (January 1st, 1970 at UTC).Note that official API docs do not mention Unix or timestamp:
https://github.com/PagerDuty/api-schema/blob/main/reference/REST/openapiv3.json
https://developer.pagerduty.com/api-reference/reference/REST/openapiv3.json/paths/~1services~1%7Bid%7D~1rules/post