@pagerduty/backstage-plugin-scaffolder-actions 0.1.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # PagerDuty plugin for Backstage - Scaffolder Actions
2
+
3
+ [![Release](https://github.com/PagerDuty/backstage-plugin-scaffolder-actions/actions/workflows/on_release_created.yml/badge.svg)](https://github.com/PagerDuty/backstage-plugin-scaffolder-actions/actions/workflows/on_release_created.yml)
4
+ [![npm version](https://badge.fury.io/js/@pagerduty%2Fbackstage-plugin-scaffolder-actions.svg)](https://badge.fury.io/js/@pagerduty%2Fbackstage-plugin--scaffolder-actions)
5
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6
+
7
+ **Bring the power of PagerDuty to Backstage!**
8
+ The PagerDuty plugin reduces the cognitive load on developers responsible for maintaining services in production. Instead of having to go to PagerDuty's console, you can now access the necessary information directly within Backstage. This includes finding active incidents or opening a new incident, reviewing recent changes made to the service, and checking who is on-call.
9
+
10
+ The PagerDuty Scaffolder Actions package allows users to create services in PagerDuty directly from their Software Templates in a single step by leveraging the `pagerduty:service:create` custom action.
11
+
12
+ ## Features
13
+
14
+ - **Scaffolder Action for creating services** This feature enables teams to create project templates that automatically generate a corresponding service in PagerDuty. These services come with a built-in integration to Backstage, which conveniently configures the frontend plugin for your service.
15
+
16
+
17
+ ## Getting Started
18
+
19
+ Find the complete project's documentation [here](https://pagerduty.github.io/backstage-plugin-docs/).
20
+
21
+ ### Installation
22
+
23
+ The installation of the PagerDuty plugin for Backstage is done with *yarn* as all other plugins in Backstage. This plugin follows a modular approach which means that every individual component will be a separate package (e.g. frontend, backend, common). In this case, you are installing a **backend plugin**.
24
+
25
+ To install this plugin run the following command from the Backstage root folder.
26
+
27
+ ```bash
28
+ yarn add --cwd packages/backend @pagerduty/backstage-plugin-scaffolder-actions @pagerduty/backstage-plugin-common
29
+ ```
30
+
31
+ ### Configuration
32
+
33
+ To use the custom actions as part of your custom project templates follow the instructions on the `Create PagerDuty service with Software Templates` section of the project's documentation [here](https://pagerduty.github.io/backstage-plugin-docs/advanced/create-service-software-template/).
34
+
35
+ ## Support
36
+
37
+ If you need help with this plugin, please open an issue in [GitHub](https://github.com/PagerDuty/backstage-plugin-scaffolder-actions), reach out on the [Backstage Discord server](https://discord.gg/backstage-687207715902193673) or [PagerDuty's community forum](https://community.pagerduty.com).
38
+
39
+ ## Contributing
40
+
41
+ If you are interested in contributing to this project, please refer to our [Contributing Guidelines](https://github.com/PagerDuty/backstage-plugin-backend/blob/main/CONTRIBUTING.md).
42
+
package/config.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright 2023 The Backstage Authors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { PagerDutyOAuthConfig } from '@pagerduty/backstage-plugin-common';
18
+
19
+ export interface Config {
20
+ /**
21
+ * Configuration for the PagerDuty plugin
22
+ * @visibility frontend
23
+ */
24
+ pagerDuty?: {
25
+ /**
26
+ * Optional Events Base URL to override the default.
27
+ * @visibility frontend
28
+ */
29
+ eventsBaseUrl?: string;
30
+ /**
31
+ * Optional API Base URL to override the default.
32
+ * @visibility frontend
33
+ */
34
+ apiBaseUrl?: string;
35
+ /**
36
+ * Optional PagerDuty API Token used in API calls from the backend component.
37
+ * @visibility secret
38
+ */
39
+ apiToken?: string;
40
+ /**
41
+ * Optional PagerDuty Scoped OAuth Token used in API calls from the backend component.
42
+ * @deepVisibility secret
43
+ */
44
+ oauth?: PagerDutyOAuthConfig;
45
+ };
46
+ }
@@ -0,0 +1,382 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var backendPluginApi = require('@backstage/backend-plugin-api');
6
+ var alpha = require('@backstage/plugin-scaffolder-node/alpha');
7
+ var pluginScaffolderNode = require('@backstage/plugin-scaffolder-node');
8
+ var zod = require('zod');
9
+ var fetch$1 = require('node-fetch');
10
+ var backstagePluginCommon = require('@pagerduty/backstage-plugin-common');
11
+
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch$1);
15
+
16
+ let authPersistence;
17
+ async function getAuthToken() {
18
+ if (authPersistence.authToken !== "" && authPersistence.authToken.includes("Bearer") && authPersistence.authTokenExpiryDate > Date.now() || authPersistence.authToken !== "" && authPersistence.authToken.includes("Token")) {
19
+ return authPersistence.authToken;
20
+ }
21
+ await loadAuthConfig(authPersistence.config, authPersistence.logger);
22
+ return authPersistence.authToken;
23
+ }
24
+ async function loadAuthConfig(config, logger) {
25
+ var _a;
26
+ try {
27
+ authPersistence = {
28
+ config,
29
+ logger,
30
+ authToken: "",
31
+ authTokenExpiryDate: Date.now()
32
+ };
33
+ if (!config.getOptionalString("pagerDuty.apiToken")) {
34
+ logger.warn("No PagerDuty API token found in config file. Trying OAuth token instead...");
35
+ if (!config.getOptional("pagerDuty.oauth")) {
36
+ logger.error("No PagerDuty OAuth configuration found in config file.");
37
+ } else if (!config.getOptionalString("pagerDuty.oauth.clientId") || !config.getOptionalString("pagerDuty.oauth.clientSecret") || !config.getOptionalString("pagerDuty.oauth.subDomain")) {
38
+ logger.error("Missing required PagerDuty OAuth parameters in config file. 'clientId', 'clientSecret', and 'subDomain' are required. 'region' is optional.");
39
+ } else {
40
+ authPersistence.authToken = await getOAuthToken(
41
+ config.getString("pagerDuty.oauth.clientId"),
42
+ config.getString("pagerDuty.oauth.clientSecret"),
43
+ config.getString("pagerDuty.oauth.subDomain"),
44
+ (_a = config.getOptionalString("pagerDuty.oauth.region")) != null ? _a : "us"
45
+ );
46
+ logger.info("PagerDuty OAuth configuration loaded successfully.");
47
+ }
48
+ } else {
49
+ authPersistence.authToken = `Token token=${config.getString("pagerDuty.apiToken")}`;
50
+ logger.info("PagerDuty API token loaded successfully.");
51
+ }
52
+ } catch (error) {
53
+ logger.error(`Unable to retrieve valid PagerDuty AUTH configuration from config file: ${error}`);
54
+ }
55
+ }
56
+ async function getOAuthToken(clientId, clientSecret, subDomain, region) {
57
+ if (!clientId || !clientSecret || !subDomain) {
58
+ throw new Error("Missing required PagerDuty OAuth parameters.");
59
+ }
60
+ const scopes = `
61
+ abilities.read
62
+ analytics.read
63
+ change_events.read
64
+ escalation_policies.read
65
+ incidents.read
66
+ oncalls.read
67
+ schedules.read
68
+ services.read
69
+ services.write
70
+ standards.read
71
+ teams.read
72
+ users.read
73
+ vendors.read
74
+ `;
75
+ const urlencoded = new URLSearchParams();
76
+ urlencoded.append("grant_type", "client_credentials");
77
+ urlencoded.append("client_id", clientId);
78
+ urlencoded.append("client_secret", clientSecret);
79
+ urlencoded.append("scope", `as_account-${region}.${subDomain} ${scopes}`);
80
+ let response;
81
+ const options = {
82
+ method: "POST",
83
+ headers: {
84
+ "Content-Type": "application/x-www-form-urlencoded"
85
+ },
86
+ body: urlencoded
87
+ };
88
+ const baseUrl = "https://identity.pagerduty.com/oauth/token";
89
+ try {
90
+ response = await fetch(baseUrl, options);
91
+ } catch (error) {
92
+ throw new Error(`Failed to retrieve oauth token: ${error}`);
93
+ }
94
+ switch (response.status) {
95
+ case 400:
96
+ throw new backstagePluginCommon.HttpError("Failed to retrieve valid token. Bad Request - Invalid arguments provided.", 400);
97
+ case 401:
98
+ throw new backstagePluginCommon.HttpError("Failed to retrieve valid token. Forbidden - Invalid credentials provided.", 401);
99
+ }
100
+ const authResponse = await response.json();
101
+ authPersistence.authTokenExpiryDate = Date.now() + authResponse.expires_in * 1e3;
102
+ return `Bearer ${authResponse.access_token}`;
103
+ }
104
+
105
+ let apiBaseUrl = "https://api.pagerduty.com";
106
+ async function createService(name, description, escalationPolicyId, alertGrouping) {
107
+ let alertGroupingParameters = "null";
108
+ let response;
109
+ const baseUrl = `${apiBaseUrl}/services`;
110
+ let body = JSON.stringify({
111
+ service: {
112
+ type: "service",
113
+ name,
114
+ description,
115
+ alert_creation: "create_alerts_and_incidents",
116
+ auto_pause_notifications_parameters: {
117
+ enabled: true,
118
+ timeout: 300
119
+ },
120
+ escalation_policy: {
121
+ id: escalationPolicyId,
122
+ type: "escalation_policy_reference"
123
+ }
124
+ }
125
+ });
126
+ if (await isEventNoiseReductionEnabled() && alertGrouping !== void 0) {
127
+ alertGroupingParameters = alertGrouping;
128
+ switch (alertGroupingParameters) {
129
+ case "intelligent":
130
+ body = JSON.stringify({
131
+ service: {
132
+ type: "service",
133
+ name,
134
+ description,
135
+ escalation_policy: {
136
+ id: escalationPolicyId,
137
+ type: "escalation_policy_reference"
138
+ },
139
+ alert_creation: "create_alerts_and_incidents",
140
+ alert_grouping_parameters: {
141
+ type: alertGroupingParameters
142
+ },
143
+ auto_pause_notifications_parameters: {
144
+ enabled: true,
145
+ timeout: 300
146
+ }
147
+ }
148
+ });
149
+ break;
150
+ case "time":
151
+ body = JSON.stringify({
152
+ service: {
153
+ type: "service",
154
+ name,
155
+ description,
156
+ escalation_policy: {
157
+ id: escalationPolicyId,
158
+ type: "escalation_policy_reference"
159
+ },
160
+ alert_creation: "create_alerts_and_incidents",
161
+ alert_grouping_parameters: {
162
+ type: alertGroupingParameters,
163
+ config: {
164
+ timeout: 0
165
+ }
166
+ },
167
+ auto_pause_notifications_parameters: {
168
+ enabled: true,
169
+ timeout: 300
170
+ }
171
+ }
172
+ });
173
+ break;
174
+ case "content_based":
175
+ body = JSON.stringify({
176
+ service: {
177
+ type: "service",
178
+ name,
179
+ description,
180
+ escalation_policy: {
181
+ id: escalationPolicyId,
182
+ type: "escalation_policy_reference"
183
+ },
184
+ alert_creation: "create_alerts_and_incidents",
185
+ alert_grouping_parameters: {
186
+ type: alertGroupingParameters,
187
+ config: {
188
+ aggregate: "all",
189
+ time_window: 0,
190
+ fields: [
191
+ "source",
192
+ "summary"
193
+ ]
194
+ }
195
+ },
196
+ auto_pause_notifications_parameters: {
197
+ enabled: true,
198
+ timeout: 300
199
+ }
200
+ }
201
+ });
202
+ break;
203
+ }
204
+ }
205
+ const options = {
206
+ method: "POST",
207
+ body,
208
+ headers: {
209
+ Authorization: await getAuthToken(),
210
+ "Accept": "application/vnd.pagerduty+json;version=2",
211
+ "Content-Type": "application/json"
212
+ }
213
+ };
214
+ try {
215
+ response = await fetch__default["default"](baseUrl, options);
216
+ } catch (error) {
217
+ throw new Error(`Failed to create service: ${error}`);
218
+ }
219
+ switch (response.status) {
220
+ case 400:
221
+ throw new Error(`Failed to create service. Caller provided invalid arguments.`);
222
+ case 401:
223
+ throw new Error(`Failed to create service. Caller did not supply credentials or did not provide the correct credentials.`);
224
+ case 402:
225
+ throw new Error(`Failed to create service. Account does not have the abilities to perform the action.`);
226
+ case 403:
227
+ throw new Error(`Failed to create service. Caller is not authorized to view the requested resource.`);
228
+ }
229
+ let result;
230
+ try {
231
+ result = await response.json();
232
+ const createServiceResult = {
233
+ url: result.service.html_url,
234
+ id: result.service.id,
235
+ alertGrouping: alertGroupingParameters
236
+ };
237
+ return createServiceResult;
238
+ } catch (error) {
239
+ throw new Error(`Failed to parse service information: ${error}`);
240
+ }
241
+ }
242
+ async function createServiceIntegration(serviceId, vendorId) {
243
+ var _a;
244
+ let response;
245
+ const baseUrl = `${apiBaseUrl}/services`;
246
+ const options = {
247
+ method: "POST",
248
+ body: JSON.stringify({
249
+ integration: {
250
+ name: "Backstage",
251
+ service: {
252
+ id: serviceId,
253
+ type: "service_reference"
254
+ },
255
+ vendor: {
256
+ id: vendorId,
257
+ type: "vendor_reference"
258
+ }
259
+ }
260
+ }),
261
+ headers: {
262
+ Authorization: await getAuthToken(),
263
+ "Accept": "application/vnd.pagerduty+json;version=2",
264
+ "Content-Type": "application/json"
265
+ }
266
+ };
267
+ try {
268
+ response = await fetch__default["default"](`${baseUrl}/${serviceId}/integrations`, options);
269
+ } catch (error) {
270
+ throw new Error(`Failed to create service: ${error}`);
271
+ }
272
+ switch (response.status) {
273
+ case 400:
274
+ throw new Error(`Failed to create service integration. Caller provided invalid arguments.`);
275
+ case 401:
276
+ throw new Error(`Failed to create service integration. Caller did not supply credentials or did not provide the correct credentials.`);
277
+ case 403:
278
+ throw new Error(`Failed to create service integration. Caller is not authorized to view the requested resource.`);
279
+ case 429:
280
+ throw new Error(`Failed to create service integration. Rate limit exceeded.`);
281
+ }
282
+ let result;
283
+ try {
284
+ result = await response.json();
285
+ return (_a = result.integration.integration_key) != null ? _a : "";
286
+ } catch (error) {
287
+ throw new Error(`Failed to parse service information: ${error}`);
288
+ }
289
+ }
290
+ async function isEventNoiseReductionEnabled() {
291
+ let response;
292
+ const baseUrl = "https://api.pagerduty.com";
293
+ const options = {
294
+ method: "GET",
295
+ headers: {
296
+ Authorization: await getAuthToken(),
297
+ "Accept": "application/vnd.pagerduty+json;version=2",
298
+ "Content-Type": "application/json"
299
+ }
300
+ };
301
+ try {
302
+ response = await fetch__default["default"](`${baseUrl}/abilities`, options);
303
+ } catch (error) {
304
+ throw new Error(`Failed to read abilities: ${error}`);
305
+ }
306
+ switch (response.status) {
307
+ case 401:
308
+ throw new Error(`Failed to read abilities. Caller did not supply credentials or did not provide the correct credentials.`);
309
+ case 403:
310
+ throw new Error(`Failed to read abilities. Caller is not authorized to view the requested resource.`);
311
+ case 429:
312
+ throw new Error(`Failed to read abilities. Rate limit exceeded.`);
313
+ }
314
+ let result;
315
+ try {
316
+ result = await response.json();
317
+ if (result.abilities.includes("preview_intelligent_alert_grouping") && result.abilities.includes("time_based_alert_grouping")) {
318
+ return true;
319
+ }
320
+ return false;
321
+ } catch (error) {
322
+ throw new Error(`Failed to parse abilities information: ${error}`);
323
+ }
324
+ }
325
+
326
+ const createPagerDutyServiceAction = () => {
327
+ return pluginScaffolderNode.createTemplateAction({
328
+ id: "pagerduty:service:create",
329
+ schema: {
330
+ input: zod.z.object({
331
+ name: zod.z.string().min(1, "name is required").describe("Name of the service"),
332
+ description: zod.z.string().min(1, "description is required").describe("Description of the service"),
333
+ escalationPolicyId: zod.z.string().min(1, "Escalation policy is required").describe("Escalation policy ID"),
334
+ alertGrouping: zod.z.string().optional().describe("Alert grouping parameters")
335
+ }),
336
+ output: zod.z.object({
337
+ serviceUrl: zod.z.string().describe("PagerDuty Service URL"),
338
+ serviceId: zod.z.string().describe("PagerDuty Service ID"),
339
+ integrationKey: zod.z.string().describe("Backstage Integration Key")
340
+ })
341
+ },
342
+ async handler(ctx) {
343
+ try {
344
+ const service = await createService(
345
+ ctx.input.name,
346
+ ctx.input.description,
347
+ ctx.input.escalationPolicyId,
348
+ ctx.input.alertGrouping
349
+ );
350
+ ctx.logger.info(`Service '${ctx.input.name}' created successfully!`);
351
+ ctx.logger.info(`Alert grouping set to '${service.alertGrouping}'`);
352
+ ctx.output("serviceUrl", service.url);
353
+ ctx.output("serviceId", service.id);
354
+ const backstageIntegrationId = "PRO19CT";
355
+ const integrationKey = await createServiceIntegration(service.id, backstageIntegrationId);
356
+ ctx.logger.info(`Backstage Integration for service '${ctx.input.name}' created successfully!`);
357
+ ctx.output("integrationKey", integrationKey);
358
+ } catch (error) {
359
+ ctx.logger.error(`${error}`);
360
+ }
361
+ }
362
+ });
363
+ };
364
+
365
+ const pagerDutyScaffolderActions = backendPluginApi.createBackendModule({
366
+ pluginId: "scaffolder",
367
+ moduleId: "custom-extensions",
368
+ register(env) {
369
+ env.registerInit({
370
+ deps: {
371
+ scaffolder: alpha.scaffolderActionsExtensionPoint
372
+ },
373
+ async init({ scaffolder }) {
374
+ scaffolder.addActions(createPagerDutyServiceAction());
375
+ }
376
+ });
377
+ }
378
+ });
379
+
380
+ exports.createPagerDutyServiceAction = createPagerDutyServiceAction;
381
+ exports["default"] = pagerDutyScaffolderActions;
382
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/auth/auth.ts","../src/apis/pagerduty.ts","../src/actions/custom.ts","../src/plugin.ts"],"sourcesContent":["import { LoggerService, RootConfigService } from \"@backstage/backend-plugin-api\";\nimport { HttpError } from \"@pagerduty/backstage-plugin-common\";\n\ntype Auth = {\n config: RootConfigService;\n logger: LoggerService;\n authToken: string;\n authTokenExpiryDate: number;\n}\n\nlet authPersistence: Auth;\n\nexport async function getAuthToken(): Promise<string> {\n // check if token already exists and is valid\n if (\n (authPersistence.authToken !== '' &&\n authPersistence.authToken.includes('Bearer') &&\n authPersistence.authTokenExpiryDate > Date.now()) // case where OAuth token is still valid\n ||\n (authPersistence.authToken !== '' &&\n authPersistence.authToken.includes('Token'))) { // case where API token is used\n return authPersistence.authToken;\n }\n\n await loadAuthConfig(authPersistence.config, authPersistence.logger);\n return authPersistence.authToken;\n}\n\nexport async function loadAuthConfig(config : RootConfigService, logger: LoggerService) {\n try {\n\n // initiliaze the authPersistence in-memory object\n authPersistence = {\n config,\n logger,\n authToken: '',\n authTokenExpiryDate: Date.now()\n };\n\n if (!config.getOptionalString('pagerDuty.apiToken')) {\n logger.warn('No PagerDuty API token found in config file. Trying OAuth token instead...');\n\n if (!config.getOptional('pagerDuty.oauth')) {\n \n logger.error('No PagerDuty OAuth configuration found in config file.');\n\n } else if (!config.getOptionalString('pagerDuty.oauth.clientId') || !config.getOptionalString('pagerDuty.oauth.clientSecret') || !config.getOptionalString('pagerDuty.oauth.subDomain')) {\n \n logger.error(\"Missing required PagerDuty OAuth parameters in config file. 'clientId', 'clientSecret', and 'subDomain' are required. 'region' is optional.\");\n\n } else {\n\n authPersistence.authToken = await getOAuthToken(\n config.getString('pagerDuty.oauth.clientId'),\n config.getString('pagerDuty.oauth.clientSecret'),\n config.getString('pagerDuty.oauth.subDomain'),\n config.getOptionalString('pagerDuty.oauth.region') ?? 'us');\n\n logger.info('PagerDuty OAuth configuration loaded successfully.');\n }\n } else {\n authPersistence.authToken = `Token token=${config.getString('pagerDuty.apiToken')}`;\n\n logger.info('PagerDuty API token loaded successfully.');\n }\n }\n catch (error) {\n logger.error(`Unable to retrieve valid PagerDuty AUTH configuration from config file: ${error}`);\n }\n}\n\nasync function getOAuthToken(clientId: string, clientSecret: string, subDomain: string, region: string): Promise<string> {\n // check if required parameters are provided\n if (!clientId || !clientSecret || !subDomain) {\n throw new Error('Missing required PagerDuty OAuth parameters.');\n }\n\n // define the scopes required for the OAuth token\n const scopes = `\n abilities.read \n analytics.read\n change_events.read \n escalation_policies.read \n incidents.read \n oncalls.read \n schedules.read \n services.read \n services.write \n standards.read\n teams.read \n users.read \n vendors.read\n `;\n\n // encode the parameters for the request\n const urlencoded = new URLSearchParams();\n urlencoded.append(\"grant_type\", \"client_credentials\");\n urlencoded.append(\"client_id\", clientId);\n urlencoded.append(\"client_secret\", clientSecret);\n urlencoded.append(\"scope\", `as_account-${region}.${subDomain} ${scopes}`);\n\n let response: Response;\n const options: RequestInit = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n },\n body: urlencoded,\n };\n const baseUrl = 'https://identity.pagerduty.com/oauth/token';\n\n try {\n response = await fetch(baseUrl, options);\n } catch (error) {\n throw new Error(`Failed to retrieve oauth token: ${error}`);\n }\n\n switch (response.status) {\n case 400:\n throw new HttpError(\"Failed to retrieve valid token. Bad Request - Invalid arguments provided.\", 400);\n case 401:\n throw new HttpError(\"Failed to retrieve valid token. Forbidden - Invalid credentials provided.\", 401);\n default: // 200\n break;\n }\n\n const authResponse = await response.json();\n authPersistence.authTokenExpiryDate = Date.now() + (authResponse.expires_in * 1000);\n return `Bearer ${authResponse.access_token}`;\n}","import fetch from 'node-fetch';\nimport type { RequestInit, Response } from 'node-fetch';\n\nimport { getAuthToken } from '../auth/auth';\nimport {\n CreateServiceResponse,\n} from '../types';\n\nimport {\n PagerDutyServiceResponse,\n PagerDutyIntegrationResponse,\n PagerDutyAbilitiesResponse,\n} from '@pagerduty/backstage-plugin-common';\n\nlet apiBaseUrl = 'https://api.pagerduty.com';\nexport function setAPIBaseUrl(url: string): void {\n apiBaseUrl = url;\n}\n\n// Supporting custom actions\nexport async function createService(name: string, description: string, escalationPolicyId: string, alertGrouping?: string): Promise<CreateServiceResponse> {\n let alertGroupingParameters = \"null\";\n let response: Response;\n const baseUrl = `${apiBaseUrl}/services`;\n\n // Set default body\n let body = JSON.stringify({\n service: {\n type: 'service',\n name: name,\n description: description,\n alert_creation: 'create_alerts_and_incidents',\n auto_pause_notifications_parameters: {\n enabled: true,\n timeout: 300,\n },\n escalation_policy: {\n id: escalationPolicyId,\n type: 'escalation_policy_reference',\n },\n },\n });\n\n // Override body if alert grouping is enabled and passed as parameter\n if (await isEventNoiseReductionEnabled() && alertGrouping !== undefined) {\n alertGroupingParameters = alertGrouping;\n\n switch (alertGroupingParameters) {\n case \"intelligent\":\n body = JSON.stringify({\n service: {\n type: 'service',\n name: name,\n description: description,\n escalation_policy: {\n id: escalationPolicyId,\n type: 'escalation_policy_reference',\n },\n alert_creation: 'create_alerts_and_incidents',\n alert_grouping_parameters: {\n type: alertGroupingParameters,\n },\n auto_pause_notifications_parameters: {\n enabled: true,\n timeout: 300,\n },\n },\n });\n break;\n case \"time\":\n body = JSON.stringify({\n service: {\n type: 'service',\n name: name,\n description: description,\n escalation_policy: {\n id: escalationPolicyId,\n type: 'escalation_policy_reference',\n },\n alert_creation: 'create_alerts_and_incidents',\n alert_grouping_parameters: {\n type: alertGroupingParameters,\n config: {\n timeout: 0,\n },\n },\n auto_pause_notifications_parameters: {\n enabled: true,\n timeout: 300,\n },\n },\n });\n break;\n case \"content_based\":\n body = JSON.stringify({\n service: {\n type: 'service',\n name: name,\n description: description,\n escalation_policy: {\n id: escalationPolicyId,\n type: 'escalation_policy_reference',\n },\n alert_creation: 'create_alerts_and_incidents',\n alert_grouping_parameters: {\n type: alertGroupingParameters,\n config: {\n aggregate: 'all',\n time_window: 0,\n fields: [\n 'source',\n 'summary',\n ],\n },\n },\n auto_pause_notifications_parameters: {\n enabled: true,\n timeout: 300,\n },\n },\n });\n break;\n default:\n break;\n }\n }\n\n const options: RequestInit = {\n method: 'POST',\n body: body,\n headers: {\n Authorization: await getAuthToken(),\n 'Accept': 'application/vnd.pagerduty+json;version=2',\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(baseUrl, options);\n } catch (error) {\n throw new Error(`Failed to create service: ${error}`);\n }\n\n switch (response.status) {\n case 400:\n throw new Error(`Failed to create service. Caller provided invalid arguments.`);\n case 401:\n throw new Error(`Failed to create service. Caller did not supply credentials or did not provide the correct credentials.`);\n case 402:\n throw new Error(`Failed to create service. Account does not have the abilities to perform the action.`);\n case 403:\n throw new Error(`Failed to create service. Caller is not authorized to view the requested resource.`);\n default: // 201\n break;\n }\n\n let result: PagerDutyServiceResponse;\n try {\n result = await response.json() as PagerDutyServiceResponse;\n\n const createServiceResult: CreateServiceResponse = {\n url: result.service.html_url,\n id: result.service.id,\n alertGrouping: alertGroupingParameters,\n };\n\n return createServiceResult;\n\n } catch (error) {\n throw new Error(`Failed to parse service information: ${error}`);\n }\n}\n\nexport async function createServiceIntegration(serviceId: string, vendorId: string): Promise<string> {\n let response: Response;\n const baseUrl = `${apiBaseUrl}/services`;\n const options: RequestInit = {\n method: 'POST',\n body: JSON.stringify({\n integration: {\n name: 'Backstage',\n service: {\n id: serviceId,\n type: 'service_reference',\n },\n vendor: {\n id: vendorId,\n type: 'vendor_reference',\n }\n }\n }),\n headers: {\n Authorization: await getAuthToken(),\n 'Accept': 'application/vnd.pagerduty+json;version=2',\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(`${baseUrl}/${serviceId}/integrations`, options);\n } catch (error) {\n throw new Error(`Failed to create service: ${error}`);\n }\n\n switch (response.status) {\n case 400:\n throw new Error(`Failed to create service integration. Caller provided invalid arguments.`);\n case 401:\n throw new Error(`Failed to create service integration. Caller did not supply credentials or did not provide the correct credentials.`);\n case 403:\n throw new Error(`Failed to create service integration. Caller is not authorized to view the requested resource.`);\n case 429:\n throw new Error(`Failed to create service integration. Rate limit exceeded.`);\n default: // 201\n break;\n }\n\n let result: PagerDutyIntegrationResponse;\n try {\n result = await response.json() as PagerDutyIntegrationResponse;\n\n return result.integration.integration_key ?? '';\n\n } catch (error) {\n throw new Error(`Failed to parse service information: ${error}`);\n }\n}\n\nexport async function isEventNoiseReductionEnabled(): Promise<boolean> {\n let response: Response;\n const baseUrl = 'https://api.pagerduty.com';\n const options: RequestInit = {\n method: 'GET',\n headers: {\n Authorization: await getAuthToken(),\n 'Accept': 'application/vnd.pagerduty+json;version=2',\n 'Content-Type': 'application/json',\n },\n };\n\n try {\n response = await fetch(`${baseUrl}/abilities`, options);\n } catch (error) {\n throw new Error(`Failed to read abilities: ${error}`);\n }\n\n switch (response.status) {\n case 401:\n throw new Error(`Failed to read abilities. Caller did not supply credentials or did not provide the correct credentials.`);\n case 403:\n throw new Error(`Failed to read abilities. Caller is not authorized to view the requested resource.`);\n case 429:\n throw new Error(`Failed to read abilities. Rate limit exceeded.`);\n default: // 200\n break;\n }\n\n let result: PagerDutyAbilitiesResponse;\n try {\n result = await response.json() as PagerDutyAbilitiesResponse;\n\n if (result.abilities.includes('preview_intelligent_alert_grouping')\n && result.abilities.includes('time_based_alert_grouping')) {\n return true;\n }\n\n return false;\n\n } catch (error) {\n throw new Error(`Failed to parse abilities information: ${error}`);\n }\n}\n","import { createTemplateAction } from '@backstage/plugin-scaffolder-node';\nimport { z } from 'zod';\nimport * as api from '../apis/pagerduty';\nimport { CreateServiceResponse } from '../types';\n\nexport const createPagerDutyServiceAction = () => {\n\n return createTemplateAction<{\n name: string;\n description: string;\n escalationPolicyId: string;\n alertGrouping?: string;\n }>({\n id: 'pagerduty:service:create',\n schema: {\n input: z.object({\n name: z.string().min(1, \"name is required\").describe('Name of the service'),\n description: z.string().min(1, \"description is required\").describe('Description of the service'),\n escalationPolicyId: z.string().min(1, \"Escalation policy is required\").describe('Escalation policy ID'),\n alertGrouping: z.string().optional().describe('Alert grouping parameters'),\n }),\n output: z.object({\n serviceUrl: z.string().describe('PagerDuty Service URL'),\n serviceId: z.string().describe('PagerDuty Service ID'),\n integrationKey: z.string().describe('Backstage Integration Key'),\n }),\n },\n\n async handler(ctx) {\n try {\n // Create service in PagerDuty\n const service: CreateServiceResponse = await api.createService(\n ctx.input.name, \n ctx.input.description, \n ctx.input.escalationPolicyId, \n ctx.input.alertGrouping);\n ctx.logger.info(`Service '${ctx.input.name}' created successfully!`);\n ctx.logger.info(`Alert grouping set to '${service.alertGrouping}'`);\n\n ctx.output('serviceUrl', service.url);\n ctx.output('serviceId', service.id);\n\n // Create Backstage Integration in PagerDuty service\n const backstageIntegrationId = 'PRO19CT'; // ID for Backstage integration\n const integrationKey = await api.createServiceIntegration(service.id, backstageIntegrationId);\n ctx.logger.info(`Backstage Integration for service '${ctx.input.name}' created successfully!`);\n\n ctx.output('integrationKey', integrationKey);\n } catch (error) {\n ctx.logger.error(`${error}`);\n }\n\n }\n });\n};\n","import { createBackendModule } from \"@backstage/backend-plugin-api\";\nimport { scaffolderActionsExtensionPoint } from \"@backstage/plugin-scaffolder-node/alpha\";\nimport { createPagerDutyServiceAction } from \"./actions/custom\";\n\n/** @public */\nexport const pagerDutyScaffolderActions = createBackendModule({\n pluginId: 'scaffolder',\n moduleId: 'custom-extensions',\n register(env) {\n env.registerInit({\n deps: {\n scaffolder: scaffolderActionsExtensionPoint,\n },\n async init({ scaffolder }) {\n scaffolder.addActions(createPagerDutyServiceAction());\n },\n });\n },\n});"],"names":["HttpError","fetch","createTemplateAction","z","api.createService","api.createServiceIntegration","createBackendModule","scaffolderActionsExtens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AAAA,eACtC,KAAO,EAAA;AACZ,QAAA,GAAA,CAAI,MAAO,CAAA,KAAA,CAAM,CAAG,EAAA,KAAK,CAAE,CAAA,CAAA,CAAA;AAAA,OAC/B;AAAA,KAEJ;AAAA,GACH,CAAA,CAAA;AACL;;ACjDO,MAAM,6BAA6BC,oCAAoB,CAAA;AAAA,EAC1D,QAAU,EAAA,YAAA;AAAA,EACV,QAAU,EAAA,mBAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACV,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACb,IAAM,EAAA;AAAA,QACF,UAAY,EAAAC,qCAAA;AAAA,OAChB;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,UAAA,EAAc,EAAA;AACvB,QAAW,UAAA,CAAA,UAAA,CAAW,8BAA8B,CAAA,CAAA;AAAA,OACxD;AAAA,KACH,CAAA,CAAA;AAAA,GACL;AACJ,CAAC;;;;;"}
@@ -0,0 +1,15 @@
1
+ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
2
+ import * as _backstage_plugin_scaffolder_node from '@backstage/plugin-scaffolder-node';
3
+ import * as _backstage_types from '@backstage/types';
4
+
5
+ /** @public */
6
+ declare const pagerDutyScaffolderActions: () => _backstage_backend_plugin_api.BackendFeature;
7
+
8
+ declare const createPagerDutyServiceAction: () => _backstage_plugin_scaffolder_node.TemplateAction<{
9
+ name: string;
10
+ description: string;
11
+ escalationPolicyId: string;
12
+ alertGrouping?: string | undefined;
13
+ }, _backstage_types.JsonObject>;
14
+
15
+ export { createPagerDutyServiceAction, pagerDutyScaffolderActions as default };
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@pagerduty/backstage-plugin-scaffolder-actions",
3
+ "version": "0.1.0-next.0",
4
+ "main": "dist/index.cjs.js",
5
+ "types": "dist/index.d.ts",
6
+ "license": "Apache-2.0",
7
+ "publishConfig": {
8
+ "access": "public",
9
+ "main": "dist/index.cjs.js",
10
+ "types": "dist/index.d.ts"
11
+ },
12
+ "backstage": {
13
+ "role": "backend-plugin"
14
+ },
15
+ "scripts": {
16
+ "start": "yarn tsc && backstage-cli package start",
17
+ "build": "yarn tsc && backstage-cli package build",
18
+ "lint": "backstage-cli package lint",
19
+ "test": "backstage-cli package test",
20
+ "clean": "backstage-cli package clean",
21
+ "prepack": "backstage-cli package prepack",
22
+ "postpack": "backstage-cli package postpack"
23
+ },
24
+ "dependencies": {
25
+ "@backstage/backend-defaults": "^0.2.16",
26
+ "@backstage/backend-plugin-api": "^0.6.16",
27
+ "@backstage/plugin-scaffolder-node": "^0.4.2",
28
+ "@rjsf/core": "^5.14.3",
29
+ "node-fetch": "^2.6.7",
30
+ "winston": "^3.2.1",
31
+ "yn": "^4.0.0",
32
+ "zod": "^3.22.4"
33
+ },
34
+ "peerDependencies": {
35
+ "@pagerduty/backstage-plugin-common": "^0.1.3"
36
+ },
37
+ "devDependencies": {
38
+ "@backstage/cli": "^0.24.0",
39
+ "@pagerduty/backstage-plugin-common": "^0.1.3",
40
+ "@types/node": "^20.9.2",
41
+ "@types/node-fetch": "2.6.11",
42
+ "@types/supertest": "^2.0.12",
43
+ "@types/webpack-env": "1.18.4",
44
+ "jest-mock": "29.7.0",
45
+ "msw": "^1.0.0",
46
+ "supertest": "^6.2.4",
47
+ "typescript": "^4.8.4"
48
+ },
49
+ "files": [
50
+ "dist",
51
+ "config.d.ts"
52
+ ],
53
+ "configSchema": "config.d.ts",
54
+ "packageManager": "yarn@3.6.3"
55
+ }