Skip to content

Commit b3eff3f

Browse files
authored
fix timestamps in examples (#795)
1 parent 29d787b commit b3eff3f

17 files changed

+47
-31
lines changed

.generator/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def unique(request):
137137

138138
TIME_FORMATTER = {
139139
"now": "new Date()",
140-
"timestamp": "{sret}.getTime() / 1000",
140+
"timestamp": "Math.round({sret}.getTime() / 1000)",
141141
"isoformat": "{sret}",
142142
"units": {
143143
"s": "new Date(new Date().getTime() / 1000 + {num})",

examples/v1/downtimes/CreateDowntime.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ const apiInstance = new v1.DowntimesApi(configuration);
1010
const params: v1.DowntimesApiCreateDowntimeRequest = {
1111
body: {
1212
message: "Example-Schedule_a_downtime_returns_OK_response",
13-
start: new Date().getTime() / 1000,
13+
start: Math.round(new Date().getTime() / 1000),
1414
timezone: "Etc/UTC",
1515
scope: ["test:examplescheduleadowntimereturnsokresponse"],
1616
recurrence: {
1717
type: "weeks",
1818
period: 1,
1919
weekDays: ["Mon", "Tue", "Wed", "Thu", "Fri"],
20-
untilDate:
21-
new Date(new Date().getTime() / 1000 + 21 * 86400).getTime() / 1000,
20+
untilDate: Math.round(
21+
new Date(new Date().getTime() / 1000 + 21 * 86400).getTime() / 1000
22+
),
2223
},
2324
},
2425
};

examples/v1/downtimes/CreateDowntime_1393233946.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ const params: v1.DowntimesApiCreateDowntimeRequest = {
1717
weekDays: ["Mon", "Tue", "Wed", "Thu", "Fri"],
1818
},
1919
scope: ["*"],
20-
start: new Date().getTime() / 1000,
21-
end: new Date(new Date().getTime() / 1000 + 1 * 3600).getTime() / 1000,
20+
start: Math.round(new Date().getTime() / 1000),
21+
end: Math.round(
22+
new Date(new Date().getTime() / 1000 + 1 * 3600).getTime() / 1000
23+
),
2224
timezone: "Etc/UTC",
2325
monitorTags: ["tag0"],
2426
},

examples/v1/downtimes/CreateDowntime_2908359488.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ const params: v1.DowntimesApiCreateDowntimeRequest = {
1313
recurrence: {
1414
period: 1,
1515
type: "weeks",
16-
untilDate:
17-
new Date(new Date().getTime() / 1000 + 21 * 86400).getTime() / 1000,
16+
untilDate: Math.round(
17+
new Date(new Date().getTime() / 1000 + 21 * 86400).getTime() / 1000
18+
),
1819
weekDays: ["Mon", "Tue", "Wed", "Thu", "Fri"],
1920
},
2021
scope: ["*"],
21-
start: new Date().getTime() / 1000,
22-
end: new Date(new Date().getTime() / 1000 + 1 * 3600).getTime() / 1000,
22+
start: Math.round(new Date().getTime() / 1000),
23+
end: Math.round(
24+
new Date(new Date().getTime() / 1000 + 1 * 3600).getTime() / 1000
25+
),
2326
timezone: "Etc/UTC",
2427
muteFirstRecoveryNotification: true,
2528
monitorTags: ["tag0"],

examples/v1/downtimes/CreateDowntime_3059354445.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ const params: v1.DowntimesApiCreateDowntimeRequest = {
1515
type: "years",
1616
},
1717
scope: ["*"],
18-
start: new Date().getTime() / 1000,
19-
end: new Date(new Date().getTime() / 1000 + 1 * 3600).getTime() / 1000,
18+
start: Math.round(new Date().getTime() / 1000),
19+
end: Math.round(
20+
new Date(new Date().getTime() / 1000 + 1 * 3600).getTime() / 1000
21+
),
2022
timezone: "Etc/UTC",
2123
muteFirstRecoveryNotification: true,
2224
monitorTags: ["tag0"],

examples/v1/downtimes/CreateDowntime_3355644446.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const MONITOR_ID = parseInt(process.env.MONITOR_ID as string);
1313
const params: v1.DowntimesApiCreateDowntimeRequest = {
1414
body: {
1515
message: "Example-Schedule_a_monitor_downtime_returns_OK_response",
16-
start: new Date().getTime() / 1000,
16+
start: Math.round(new Date().getTime() / 1000),
1717
timezone: "Etc/UTC",
1818
scope: ["test:examplescheduleamonitordowntimereturnsokresponse"],
1919
monitorId: MONITOR_ID,

examples/v1/metrics/QueryMetrics.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ const configuration = client.createConfiguration();
88
const apiInstance = new v1.MetricsApi(configuration);
99

1010
const params: v1.MetricsApiQueryMetricsRequest = {
11-
from: new Date(new Date().getTime() / 1000 + -1 * 86400).getTime() / 1000,
12-
to: new Date().getTime() / 1000,
11+
from: Math.round(
12+
new Date(new Date().getTime() / 1000 + -1 * 86400).getTime() / 1000
13+
),
14+
to: Math.round(new Date().getTime() / 1000),
1315
query: "system.cpu.idle{*}",
1416
};
1517

examples/v1/metrics/SubmitDistributionPoints.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const params: v1.MetricsApiSubmitDistributionPointsRequest = {
1212
series: [
1313
{
1414
metric: "system.load.1.dist",
15-
points: [[new Date().getTime() / 1000, [1.0, 2.0]]],
15+
points: [[Math.round(new Date().getTime() / 1000), [1.0, 2.0]]],
1616
},
1717
],
1818
},

examples/v1/metrics/SubmitDistributionPoints_3109558960.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const params: v1.MetricsApiSubmitDistributionPointsRequest = {
1212
series: [
1313
{
1414
metric: "system.load.1.dist",
15-
points: [[new Date().getTime() / 1000, [1.0, 2.0]]],
15+
points: [[Math.round(new Date().getTime() / 1000), [1.0, 2.0]]],
1616
},
1717
],
1818
},

examples/v1/metrics/SubmitMetrics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const params: v1.MetricsApiSubmitMetricsRequest = {
1313
{
1414
metric: "system.load.1",
1515
type: "gauge",
16-
points: [[new Date().getTime() / 1000, 1.1]],
16+
points: [[Math.round(new Date().getTime() / 1000), 1.1]],
1717
tags: ["test:ExampleSubmitmetricsreturnsPayloadacceptedresponse"],
1818
},
1919
],

0 commit comments

Comments
 (0)