Skip to content

Commit 24d693f

Browse files
Add MaintenanceService for scheduled maintenance windows (#7)
- Add maintenance service with CRUD operations (create, get, list, update, delete) - Export Maintenance and MaintenanceSummary types - Export all maintenance request/response types - Add maintenance namespace to OpenStatusClient interface - Update README with maintenance service documentation - Remove non-existent Maintenance export from status page types
1 parent cb1724a commit 24d693f

8 files changed

Lines changed: 744 additions & 94 deletions

File tree

README.md

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ status page with uptime monitoring.
1414
- **Status Pages** - Create and manage public status pages with custom domains
1515
- **Page Components** - Add monitor-based or static components with grouping
1616
- **Subscribers** - Manage email subscriptions for status updates
17-
- **Status Reports** - Manage incident and maintenance reports with update
18-
timelines
17+
- **Status Reports** - Manage incident reports with update timelines
18+
- **Maintenance Windows** - Schedule and manage planned maintenance periods
1919

2020
### Monitoring
2121

@@ -733,6 +733,94 @@ for (const { componentId, status } of componentStatuses) {
733733
}
734734
```
735735

736+
### Maintenance Service
737+
738+
Manage scheduled maintenance windows.
739+
740+
#### `createMaintenance(request, options)`
741+
742+
Create a new maintenance window.
743+
744+
```typescript
745+
const { maintenance } = await openstatus.maintenance.v1.MaintenanceService
746+
.createMaintenance(
747+
{
748+
title: "Database Upgrade",
749+
message: "We will be upgrading our database infrastructure.",
750+
from: "2024-01-20T02:00:00Z",
751+
to: "2024-01-20T04:00:00Z",
752+
pageId: "page_123",
753+
pageComponentIds: ["comp_456"],
754+
notify: true,
755+
},
756+
{ headers },
757+
);
758+
759+
console.log(`Maintenance created: ${maintenance?.id}`);
760+
```
761+
762+
#### `getMaintenance(request, options)`
763+
764+
Get a maintenance window by ID.
765+
766+
```typescript
767+
const { maintenance } = await openstatus.maintenance.v1.MaintenanceService
768+
.getMaintenance(
769+
{ id: "maint_123" },
770+
{ headers },
771+
);
772+
773+
console.log(`Title: ${maintenance?.title}`);
774+
console.log(`From: ${maintenance?.from}`);
775+
console.log(`To: ${maintenance?.to}`);
776+
```
777+
778+
#### `listMaintenances(request, options)`
779+
780+
List all maintenance windows with pagination and optional filtering.
781+
782+
```typescript
783+
const { maintenances, totalSize } = await openstatus.maintenance.v1
784+
.MaintenanceService.listMaintenances(
785+
{
786+
limit: 10,
787+
offset: 0,
788+
pageId: "page_123", // optional filter
789+
},
790+
{ headers },
791+
);
792+
793+
console.log(`Found ${totalSize} maintenance windows`);
794+
```
795+
796+
#### `updateMaintenance(request, options)`
797+
798+
Update a maintenance window.
799+
800+
```typescript
801+
const { maintenance } = await openstatus.maintenance.v1.MaintenanceService
802+
.updateMaintenance(
803+
{
804+
id: "maint_123",
805+
title: "Extended Database Upgrade",
806+
to: "2024-01-20T06:00:00Z",
807+
},
808+
{ headers },
809+
);
810+
```
811+
812+
#### `deleteMaintenance(request, options)`
813+
814+
Delete a maintenance window.
815+
816+
```typescript
817+
const { success } = await openstatus.maintenance.v1.MaintenanceService
818+
.deleteMaintenance(
819+
{ id: "maint_123" },
820+
{ headers },
821+
);
822+
```
823+
736824
### Status Page Options
737825

738826
| Option | Type | Required | Description |
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
// @generated by protoc-gen-es v2.11.0 with parameter "target=ts,import_extension=ts"
2+
// @generated from file openstatus/maintenance/v1/maintenance.proto (package openstatus.maintenance.v1, syntax proto3)
3+
/* eslint-disable */
4+
5+
import type { GenFile, GenMessage } from "@bufbuild/protobuf/codegenv2";
6+
import { fileDesc, messageDesc } from "@bufbuild/protobuf/codegenv2";
7+
import type { Message } from "@bufbuild/protobuf";
8+
9+
/**
10+
* Describes the file openstatus/maintenance/v1/maintenance.proto.
11+
*/
12+
export const file_openstatus_maintenance_v1_maintenance: GenFile = /*@__PURE__*/
13+
fileDesc(
14+
"CitvcGVuc3RhdHVzL21haW50ZW5hbmNlL3YxL21haW50ZW5hbmNlLnByb3RvEhlvcGVuc3RhdHVzLm1haW50ZW5hbmNlLnYxIq8BChJNYWludGVuYW5jZVN1bW1hcnkSCgoCaWQYASABKAkSDQoFdGl0bGUYAiABKAkSDwoHbWVzc2FnZRgDIAEoCRIMCgRmcm9tGAQgASgJEgoKAnRvGAUgASgJEg8KB3BhZ2VfaWQYBiABKAkSGgoScGFnZV9jb21wb25lbnRfaWRzGAcgAygJEhIKCmNyZWF0ZWRfYXQYCCABKAkSEgoKdXBkYXRlZF9hdBgJIAEoCSKoAQoLTWFpbnRlbmFuY2USCgoCaWQYASABKAkSDQoFdGl0bGUYAiABKAkSDwoHbWVzc2FnZRgDIAEoCRIMCgRmcm9tGAQgASgJEgoKAnRvGAUgASgJEg8KB3BhZ2VfaWQYBiABKAkSGgoScGFnZV9jb21wb25lbnRfaWRzGAcgAygJEhIKCmNyZWF0ZWRfYXQYCCABKAkSEgoKdXBkYXRlZF9hdBgJIAEoCUJbWllnaXRodWIuY29tL29wZW5zdGF0dXNocS9vcGVuc3RhdHVzL3BhY2thZ2VzL3Byb3RvL29wZW5zdGF0dXMvbWFpbnRlbmFuY2UvdjE7bWFpbnRlbmFuY2V2MWIGcHJvdG8z",
15+
);
16+
17+
/**
18+
* MaintenanceSummary represents metadata for a maintenance window (used in list responses).
19+
*
20+
* @generated from message openstatus.maintenance.v1.MaintenanceSummary
21+
*/
22+
export type MaintenanceSummary =
23+
& Message<"openstatus.maintenance.v1.MaintenanceSummary">
24+
& {
25+
/**
26+
* Unique identifier for the maintenance.
27+
*
28+
* @generated from field: string id = 1;
29+
*/
30+
id: string;
31+
32+
/**
33+
* Title of the maintenance.
34+
*
35+
* @generated from field: string title = 2;
36+
*/
37+
title: string;
38+
39+
/**
40+
* Message describing the maintenance.
41+
*
42+
* @generated from field: string message = 3;
43+
*/
44+
message: string;
45+
46+
/**
47+
* Start time of the maintenance window (RFC 3339 format).
48+
*
49+
* @generated from field: string from = 4;
50+
*/
51+
from: string;
52+
53+
/**
54+
* End time of the maintenance window (RFC 3339 format).
55+
*
56+
* @generated from field: string to = 5;
57+
*/
58+
to: string;
59+
60+
/**
61+
* ID of the page this maintenance is associated with.
62+
*
63+
* @generated from field: string page_id = 6;
64+
*/
65+
pageId: string;
66+
67+
/**
68+
* IDs of affected page components.
69+
*
70+
* @generated from field: repeated string page_component_ids = 7;
71+
*/
72+
pageComponentIds: string[];
73+
74+
/**
75+
* Timestamp when the maintenance was created (RFC 3339 format).
76+
*
77+
* @generated from field: string created_at = 8;
78+
*/
79+
createdAt: string;
80+
81+
/**
82+
* Timestamp when the maintenance was last updated (RFC 3339 format).
83+
*
84+
* @generated from field: string updated_at = 9;
85+
*/
86+
updatedAt: string;
87+
};
88+
89+
/**
90+
* Describes the message openstatus.maintenance.v1.MaintenanceSummary.
91+
* Use `create(MaintenanceSummarySchema)` to create a new message.
92+
*/
93+
export const MaintenanceSummarySchema: GenMessage<
94+
MaintenanceSummary
95+
> = /*@__PURE__*/
96+
messageDesc(file_openstatus_maintenance_v1_maintenance, 0);
97+
98+
/**
99+
* Maintenance represents a maintenance window with full details.
100+
*
101+
* @generated from message openstatus.maintenance.v1.Maintenance
102+
*/
103+
export type Maintenance = Message<"openstatus.maintenance.v1.Maintenance"> & {
104+
/**
105+
* Unique identifier for the maintenance.
106+
*
107+
* @generated from field: string id = 1;
108+
*/
109+
id: string;
110+
111+
/**
112+
* Title of the maintenance.
113+
*
114+
* @generated from field: string title = 2;
115+
*/
116+
title: string;
117+
118+
/**
119+
* Message describing the maintenance.
120+
*
121+
* @generated from field: string message = 3;
122+
*/
123+
message: string;
124+
125+
/**
126+
* Start time of the maintenance window (RFC 3339 format).
127+
*
128+
* @generated from field: string from = 4;
129+
*/
130+
from: string;
131+
132+
/**
133+
* End time of the maintenance window (RFC 3339 format).
134+
*
135+
* @generated from field: string to = 5;
136+
*/
137+
to: string;
138+
139+
/**
140+
* ID of the page this maintenance is associated with.
141+
*
142+
* @generated from field: string page_id = 6;
143+
*/
144+
pageId: string;
145+
146+
/**
147+
* IDs of affected page components.
148+
*
149+
* @generated from field: repeated string page_component_ids = 7;
150+
*/
151+
pageComponentIds: string[];
152+
153+
/**
154+
* Timestamp when the maintenance was created (RFC 3339 format).
155+
*
156+
* @generated from field: string created_at = 8;
157+
*/
158+
createdAt: string;
159+
160+
/**
161+
* Timestamp when the maintenance was last updated (RFC 3339 format).
162+
*
163+
* @generated from field: string updated_at = 9;
164+
*/
165+
updatedAt: string;
166+
};
167+
168+
/**
169+
* Describes the message openstatus.maintenance.v1.Maintenance.
170+
* Use `create(MaintenanceSchema)` to create a new message.
171+
*/
172+
export const MaintenanceSchema: GenMessage<Maintenance> = /*@__PURE__*/
173+
messageDesc(file_openstatus_maintenance_v1_maintenance, 1);

0 commit comments

Comments
 (0)