pagerduty

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-08-19 13:10:51 +02:00
parent 6a001acf8c
commit 9a5a1681c1
10 changed files with 40 additions and 53 deletions
+14 -47
View File
@@ -13,26 +13,30 @@ import { Entity } from '@backstage/catalog-model';
import { FetchApi } from '@backstage/core-plugin-api';
import { ReactNode } from 'react';
// Warning: (ae-missing-release-tag) "EntityPagerDutyCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const EntityPagerDutyCard: () => JSX.Element;
// Warning: (ae-missing-release-tag) "isPluginApplicableToEntity" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
const isPluginApplicableToEntity: (entity: Entity) => boolean;
export { isPluginApplicableToEntity as isPagerDutyAvailable };
export { isPluginApplicableToEntity };
// Warning: (ae-forgotten-export) The symbol "PagerDutyApi" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "pagerDutyApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface PagerDutyApi {
getChangeEventsByServiceId(
serviceId: string,
): Promise<PagerDutyChangeEventsResponse>;
getIncidentsByServiceId(
serviceId: string,
): Promise<PagerDutyIncidentsResponse>;
getOnCallByPolicyId(policyId: string): Promise<PagerDutyOnCallsResponse>;
getServiceByEntity(entity: Entity): Promise<PagerDutyServiceResponse>;
triggerAlarm(request: PagerDutyTriggerAlarmRequest): Promise<Response>;
}
// @public (undocumented)
export const pagerDutyApiRef: ApiRef<PagerDutyApi>;
// Warning: (ae-missing-release-tag) "PagerDutyAssignee" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyAssignee = {
id: string;
@@ -40,13 +44,9 @@ export type PagerDutyAssignee = {
html_url: string;
};
// Warning: (ae-missing-release-tag) "PagerDutyCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const PagerDutyCard: () => JSX.Element;
// Warning: (ae-missing-release-tag) "PagerDutyChangeEvent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyChangeEvent = {
id: string;
@@ -67,15 +67,11 @@ export type PagerDutyChangeEvent = {
timestamp: string;
};
// Warning: (ae-missing-release-tag) "PagerDutyChangeEventsResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyChangeEventsResponse = {
change_events: PagerDutyChangeEvent[];
};
// Warning: (ae-missing-release-tag) "PagerDutyClient" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export class PagerDutyClient implements PagerDutyApi {
constructor(config: PagerDutyClientApiConfig);
@@ -100,23 +96,17 @@ export class PagerDutyClient implements PagerDutyApi {
triggerAlarm(request: PagerDutyTriggerAlarmRequest): Promise<Response>;
}
// Warning: (ae-missing-release-tag) "PagerDutyClientApiConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyClientApiConfig = PagerDutyClientApiDependencies & {
eventsBaseUrl?: string;
};
// Warning: (ae-missing-release-tag) "PagerDutyClientApiDependencies" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyClientApiDependencies = {
discoveryApi: DiscoveryApi;
fetchApi: FetchApi;
};
// Warning: (ae-missing-release-tag) "PagerDutyEntity" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyEntity = {
integrationKey?: string;
@@ -124,8 +114,6 @@ export type PagerDutyEntity = {
name: string;
};
// Warning: (ae-missing-release-tag) "PagerDutyIncident" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyIncident = {
id: string;
@@ -141,37 +129,27 @@ export type PagerDutyIncident = {
created_at: string;
};
// Warning: (ae-missing-release-tag) "PagerDutyIncidentsResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyIncidentsResponse = {
incidents: PagerDutyIncident[];
};
// Warning: (ae-missing-release-tag) "PagerDutyOnCall" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyOnCall = {
user: PagerDutyUser;
escalation_level: number;
};
// Warning: (ae-missing-release-tag) "PagerDutyOnCallsResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyOnCallsResponse = {
oncalls: PagerDutyOnCall[];
};
// Warning: (ae-missing-release-tag) "pagerDutyPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
const pagerDutyPlugin: BackstagePlugin<{}, {}, {}>;
export { pagerDutyPlugin };
export { pagerDutyPlugin as plugin };
// Warning: (ae-missing-release-tag) "PagerDutyService" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyService = {
id: string;
@@ -185,15 +163,11 @@ export type PagerDutyService = {
};
};
// Warning: (ae-missing-release-tag) "PagerDutyServiceResponse" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyServiceResponse = {
service: PagerDutyService;
};
// Warning: (ae-missing-release-tag) "PagerDutyTriggerAlarmRequest" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyTriggerAlarmRequest = {
integrationKey: string;
@@ -202,8 +176,6 @@ export type PagerDutyTriggerAlarmRequest = {
userName: string;
};
// Warning: (ae-missing-release-tag) "PagerDutyUser" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type PagerDutyUser = {
id: string;
@@ -213,14 +185,9 @@ export type PagerDutyUser = {
name: string;
};
// Warning: (ae-forgotten-export) The symbol "TriggerButtonProps" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "TriggerButton" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export function TriggerButton(props: TriggerButtonProps): JSX.Element;
export function TriggerButton(props: { children?: ReactNode }): JSX.Element;
// Warning: (ae-missing-release-tag) "UnauthorizedError" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export class UnauthorizedError extends Error {}
```
+3
View File
@@ -31,8 +31,10 @@ import { NotFoundError } from '@backstage/errors';
import { Entity } from '@backstage/catalog-model';
import { getPagerDutyEntity } from '../components/pagerDutyEntity';
/** @public */
export class UnauthorizedError extends Error {}
/** @public */
export const pagerDutyApiRef = createApiRef<PagerDutyApi>({
id: 'plugin.pagerduty.api',
});
@@ -40,6 +42,7 @@ export const pagerDutyApiRef = createApiRef<PagerDutyApi>({
const commonGetServiceParams =
'time_zone=UTC&include[]=integrations&include[]=escalation_policies';
/** @public */
export class PagerDutyClient implements PagerDutyApi {
static fromConfig(
configApi: ConfigApi,
+1
View File
@@ -16,6 +16,7 @@
export { PagerDutyClient, pagerDutyApiRef, UnauthorizedError } from './client';
export type {
PagerDutyApi,
PagerDutyServiceResponse,
PagerDutyIncidentsResponse,
PagerDutyChangeEventsResponse,
+8
View File
@@ -27,22 +27,27 @@ export type PagerDutyServicesResponse = {
services: PagerDutyService[];
};
/** @public */
export type PagerDutyServiceResponse = {
service: PagerDutyService;
};
/** @public */
export type PagerDutyIncidentsResponse = {
incidents: PagerDutyIncident[];
};
/** @public */
export type PagerDutyChangeEventsResponse = {
change_events: PagerDutyChangeEvent[];
};
/** @public */
export type PagerDutyOnCallsResponse = {
oncalls: PagerDutyOnCall[];
};
/** @public */
export type PagerDutyTriggerAlarmRequest = {
integrationKey: string;
source: string;
@@ -50,6 +55,7 @@ export type PagerDutyTriggerAlarmRequest = {
userName: string;
};
/** @public */
export interface PagerDutyApi {
/**
* Fetches the service for the provided Entity.
@@ -85,11 +91,13 @@ export interface PagerDutyApi {
triggerAlarm(request: PagerDutyTriggerAlarmRequest): Promise<Response>;
}
/** @public */
export type PagerDutyClientApiDependencies = {
discoveryApi: DiscoveryApi;
fetchApi: FetchApi;
};
/** @public */
export type PagerDutyClientApiConfig = PagerDutyClientApiDependencies & {
eventsBaseUrl?: string;
};
@@ -46,12 +46,14 @@ const BasicCard = ({ children }: { children: ReactNode }) => (
<InfoCard title="PagerDuty">{children}</InfoCard>
);
/** @public */
export const isPluginApplicableToEntity = (entity: Entity) =>
Boolean(
entity.metadata.annotations?.[PAGERDUTY_INTEGRATION_KEY] ||
entity.metadata.annotations?.[PAGERDUTY_SERVICE_ID],
);
/** @public */
export const PagerDutyCard = () => {
const { entity } = useEntity();
const pagerDutyEntity = getPagerDutyEntity(entity);
@@ -20,10 +20,6 @@ import { BackstageTheme } from '@backstage/theme';
import { usePagerdutyEntity } from '../../hooks';
import { TriggerDialog } from '../TriggerDialog';
export type TriggerButtonProps = {
children?: ReactNode;
};
const useStyles = makeStyles<BackstageTheme>(theme => ({
buttonStyle: {
backgroundColor: theme.palette.error.main,
@@ -34,7 +30,8 @@ const useStyles = makeStyles<BackstageTheme>(theme => ({
},
}));
export function TriggerButton(props: TriggerButtonProps) {
/** @public */
export function TriggerButton(props: { children?: ReactNode }) {
const { buttonStyle } = useStyles();
const { integrationKey } = usePagerdutyEntity();
const [dialogShown, setDialogShown] = useState<boolean>(false);
@@ -14,6 +14,7 @@
* limitations under the License.
*/
/** @public */
export type PagerDutyChangeEvent = {
id: string;
integration: [
@@ -33,6 +34,7 @@ export type PagerDutyChangeEvent = {
timestamp: string;
};
/** @public */
export type PagerDutyIncident = {
id: string;
title: string;
@@ -47,6 +49,7 @@ export type PagerDutyIncident = {
created_at: string;
};
/** @public */
export type PagerDutyService = {
id: string;
name: string;
@@ -59,17 +62,20 @@ export type PagerDutyService = {
};
};
/** @public */
export type PagerDutyOnCall = {
user: PagerDutyUser;
escalation_level: number;
};
/** @public */
export type PagerDutyAssignee = {
id: string;
summary: string;
html_url: string;
};
/** @public */
export type PagerDutyUser = {
id: string;
summary: string;
@@ -78,6 +84,7 @@ export type PagerDutyUser = {
name: string;
};
/** @public */
export type SubHeaderLink = {
title: string;
href?: string;
+2
View File
@@ -28,6 +28,7 @@ export const rootRouteRef = createRouteRef({
id: 'pagerduty',
});
/** @public */
export const pagerDutyPlugin = createPlugin({
id: 'pagerduty',
apis: [
@@ -44,6 +45,7 @@ export const pagerDutyPlugin = createPlugin({
],
});
/** @public */
export const EntityPagerDutyCard = pagerDutyPlugin.provide(
createComponentExtension({
name: 'EntityPagerDutyCard',
+1
View File
@@ -14,6 +14,7 @@
* limitations under the License.
*/
/** @public */
export type PagerDutyEntity = {
integrationKey?: string;
serviceId?: string;
-1
View File
@@ -229,7 +229,6 @@ const ALLOW_WARNINGS = [
'plugins/kubernetes-common',
'plugins/newrelic',
'plugins/newrelic-dashboard',
'plugins/pagerduty',
];
async function resolvePackagePath(