@@ -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,
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
export { PagerDutyClient, pagerDutyApiRef, UnauthorizedError } from './client';
|
||||
export type {
|
||||
PagerDutyApi,
|
||||
PagerDutyServiceResponse,
|
||||
PagerDutyIncidentsResponse,
|
||||
PagerDutyChangeEventsResponse,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** @public */
|
||||
export type PagerDutyEntity = {
|
||||
integrationKey?: string;
|
||||
serviceId?: string;
|
||||
|
||||
Reference in New Issue
Block a user