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

release: 0.13.0 #115

Merged
merged 14 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/on_release_created.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
default: true
type: boolean
version:
description: 'Test scenario tags'
description: 'Version'
required: true
type: string

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The PagerDuty plugin reduces the cognitive load on developers responsible for ma
- **[See Active Incidents](<https://pagerduty.github.io/backstage-plugin-docs/capabilities/#view-any-open-incidents>)** - View all active incidents for a service directly in Backstage.
- **[Check for Recent Changes](<https://pagerduty.github.io/backstage-plugin-docs/capabilities/#view-change-events-associated-to-a-service>)** - Identify recent changes that may be the root cause of potential issues with your service.
- **[Identify On-Call Personnel](<https://pagerduty.github.io/backstage-plugin-docs/capabilities/#see-and-contact-on-call-staff>)** - Quickly determine who is responsible for a failing service and resolve the incident as quickly as possible. This feature allows companies to spend more time solving problems rather than determining who should solve them.
- **Map existing PagerDuty services to Backstage entities** - Leverage PagerDuty's Advanced Configuration page to map existing PagerDuty services to Backstage entities without code changes.

## Getting Started

Expand Down
39 changes: 39 additions & 0 deletions dev/mockPagerDutyApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,47 @@ import {
} from '../src';
import { PagerDutyChangeEvent, PagerDutyIncident, PagerDutyUser } from '@pagerduty/backstage-plugin-common';
import { Entity } from '@backstage/catalog-model';
import { v4 as uuidv4 } from 'uuid';

export const mockPagerDutyApi: PagerDutyApi = {
async getEntityMappings() {
return {
mappings: [
{
serviceId: "SERV1CE1D",
entityRef: "ENTITY1D",
entityName: "Entity1",
integrationKey: "INTEGRAT1ONKEY1",
team: "Team1",
serviceName: "Service1",
serviceUrl: "http://service1",
escalationPolicy: "Escalation Policy 1",
status: "InSync",
},
{
serviceId: "SERV1CE1D",
entityRef: "",
entityName: "Entity2",
integrationKey: "INTEGRAT1ONKEY2",
status: "NotMapped",
team: "Team1",
serviceName: "Service2",
serviceUrl: "http://service2",
escalationPolicy: "Escalation Policy 1",
}
]
}
},
async storeServiceMapping(serviceId, entityId) {
const uuid = uuidv4();


return new Response(JSON.stringify({
service_id: serviceId,
entity_id: entityId,
id: uuid,
}));
},
async getServiceByPagerDutyEntity(pagerDutyEntity: PagerDutyEntity) {
return {
service: {
Expand Down
18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,27 @@
"@backstage/plugin-catalog-react": "^1.12.0",
"@backstage/plugin-home-react": "^0.1.13",
"@backstage/theme": "^0.5.5",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "4.0.0-alpha.61",
"@mui/icons-material": "^5.15.19",
"@mui/material": "^5.15.19",
"@mui/x-date-pickers": "^7.6.1",
"@pagerduty/backstage-plugin-common": "0.1.5",
"@tanstack/react-query": "^5.40.1",
"classnames": "^2.2.6",
"luxon": "^3.4.1",
"material-react-table": "^2.13.0",
"react-use": "^17.2.4",
"uuid": "^10.0.0",
"validate-color": "^2.2.4"
},
"peerDependencies": {
"@pagerduty/backstage-plugin-common": "^0.1.2",
"react": "^16.13.1 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
"react": "^18.0.0 || ^20.0.0",
"react-dom": "^18.0.0 || ^20.0.0",
"react-router-dom": "^6.3.0"
},
"devDependencies": {
"@backstage/cli": "^0.26.6",
Expand All @@ -61,7 +69,6 @@
"@backstage/test-utils": "^1.5.5",
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@pagerduty/backstage-plugin-common": "^0.1.2",
"@testing-library/dom": "^8.0.0",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3",
Expand All @@ -70,6 +77,7 @@
"@types/luxon": "^3.3.1",
"@types/node": "^16.11.26",
"@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
"@types/uuid": "^10.0.0",
"copyfiles": "^2.4.1",
"msw": "^1.2.4",
"react": "^16.13.1 || ^17.0.0 || ^18.0.0",
Expand Down
35 changes: 34 additions & 1 deletion src/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import { PagerDutyChangeEventsResponse,
PagerDutyServiceResponse,
PagerDutyIncidentsResponse,
PagerDutyServiceStandardsResponse,
PagerDutyServiceMetricsResponse
PagerDutyServiceMetricsResponse,
PagerDutyEntityMappingsResponse
} from '@pagerduty/backstage-plugin-common';
import { createApiRef, ConfigApi } from '@backstage/core-plugin-api';
import { NotFoundError } from '@backstage/errors';
Expand Down Expand Up @@ -97,6 +98,38 @@ export class PagerDutyClient implements PagerDutyApi {
return response;
}

async getEntityMappings(): Promise<PagerDutyEntityMappingsResponse> {
const url = `${await this.config.discoveryApi.getBaseUrl(
'pagerduty',
)}/mapping/entity`;

return await this.findByUrl<PagerDutyEntityMappingsResponse>(url);
}

async storeServiceMapping(serviceId: string, integrationKey: string, backstageEntityRef: string): Promise<Response> {

const body = JSON.stringify({
entityRef: backstageEntityRef,
serviceId: serviceId,
integrationKey: integrationKey,
});

const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
Accept: 'application/json, text/plain, */*',
},
body,
};

const url = `${await this.config.discoveryApi.getBaseUrl(
'pagerduty',
)}/mapping/entity`;

return this.request(url, options);
}

async getServiceByEntity(entity: Entity): Promise<PagerDutyServiceResponse> {
return await this.getServiceByPagerDutyEntity(getPagerDutyEntity(entity));
}
Expand Down
15 changes: 14 additions & 1 deletion src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { PagerDutyChangeEventsResponse,
PagerDutyServiceStandardsResponse,
PagerDutyServiceMetricsResponse,
PagerDutyServiceStandards,
PagerDutyServiceMetrics
PagerDutyServiceMetrics,
PagerDutyEntityMappingsResponse
} from '@pagerduty/backstage-plugin-common';
import { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';
import { Entity } from '@backstage/catalog-model';
Expand Down Expand Up @@ -50,6 +51,18 @@ export type PagerDutyCardServiceResponse = {

/** @public */
export interface PagerDutyApi {
/**
* Fetches all entity mappings.
*
*/
getEntityMappings(): Promise<PagerDutyEntityMappingsResponse>;

/**
* Stores the service mapping in the database.
*
*/
storeServiceMapping(serviceId: string, integrationKey: string, entityRef: string): Promise<Response>;

/**
* Fetches the service for the provided pager duty Entity.
*
Expand Down
13 changes: 13 additions & 0 deletions src/assets/PD-Icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/components/Icons/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";
import PDIcon from "../../assets/PD-Icon.svg";

/** @public */
export function PagerDutyIcon() {

return <img src={PDIcon} alt="PagerDuty" height="20px" />;
};
Loading
Loading