From 3ec16d2c4187dc9e3a1e4bbb94a75d80ad98c612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Fri, 19 Aug 2022 12:25:57 +0200 Subject: [PATCH] splunk-on-call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- plugins/splunk-on-call/api-report.md | 246 +++++++++++++++--- plugins/splunk-on-call/src/api/client.ts | 3 + plugins/splunk-on-call/src/api/index.ts | 2 +- plugins/splunk-on-call/src/api/types.ts | 10 + .../src/components/EntitySplunkOnCallCard.tsx | 1 + .../src/components/SplunkOnCallPage.tsx | 1 + .../splunk-on-call/src/components/index.ts | 20 ++ .../splunk-on-call/src/components/types.ts | 16 ++ plugins/splunk-on-call/src/index.ts | 8 +- plugins/splunk-on-call/src/plugin.ts | 3 + scripts/api-extractor.ts | 1 - 11 files changed, 269 insertions(+), 42 deletions(-) create mode 100644 plugins/splunk-on-call/src/components/index.ts diff --git a/plugins/splunk-on-call/api-report.md b/plugins/splunk-on-call/api-report.md index b24a68e07a..e0609c5b82 100644 --- a/plugins/splunk-on-call/api-report.md +++ b/plugins/splunk-on-call/api-report.md @@ -12,62 +12,207 @@ import { DiscoveryApi } from '@backstage/core-plugin-api'; import { Entity } from '@backstage/catalog-model'; import { RouteRef } from '@backstage/core-plugin-api'; -// Warning: (ae-forgotten-export) The symbol "EntitySplunkOnCallCardProps" needs to be exported by the entry point index.d.ts -// Warning: (ae-missing-release-tag) "EntitySplunkOnCallCard" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// +// @public (undocumented) +export type ClientApiConfig = { + eventsRestEndpoint: string | null; + discoveryApi: DiscoveryApi; +}; + // @public (undocumented) export const EntitySplunkOnCallCard: ( props: EntitySplunkOnCallCardProps, ) => JSX.Element; -// Warning: (ae-missing-release-tag) "isSplunkOnCallAvailable" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// +// @public (undocumented) +export type EntitySplunkOnCallCardProps = { + readOnly?: boolean; +}; + +// @public (undocumented) +export type EscalationPolicyInfo = { + policy: EscalationPolicySummary; + team?: EscalationPolicyTeam; +}; + +// @public (undocumented) +export type EscalationPolicyResponse = { + policies: EscalationPolicyInfo[]; +}; + +// @public (undocumented) +export type EscalationPolicySummary = { + name: string; + slug: string; + _selfUrl: string; +}; + +// @public (undocumented) +export type EscalationPolicyTeam = { + name: string; + slug: string; +}; + +// @public (undocumented) +export type Incident = { + incidentNumber?: string; + startTime?: string; + currentPhase: IncidentPhase; + entityState?: string; + entityType?: string; + routingKey?: string; + alertCount?: number; + lastAlertTime?: string; + lastAlertId?: string; + entityId: string; + host?: string; + service?: string; + pagedUsers?: string[]; + pagedTeams?: string[]; + entityDisplayName?: string; + pagedPolicies?: EscalationPolicyInfo[]; + transitions?: IncidentTransition[]; + firstAlertUuid?: string; + monitorName?: string; + monitorType?: string; + incidentLink?: string; +}; + +// @public (undocumented) +export type IncidentPhase = 'UNACKED' | 'ACKED' | 'RESOLVED'; + +// @public (undocumented) +export type IncidentsResponse = { + incidents: Incident[]; +}; + +// @public (undocumented) +export type IncidentTransition = { + name?: string; + at?: string; + by?: string; + message?: string; + manually?: boolean; + alertId?: string; + alertUrl?: string; +}; + // @public (undocumented) export const isSplunkOnCallAvailable: (entity: Entity) => boolean; -// Warning: (ae-forgotten-export) The symbol "SplunkOnCallApi" needs to be exported by the entry point index.d.ts -// Warning: (ae-missing-release-tag) "splunkOnCallApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// +// @public (undocumented) +export type ListRoutingKeyResponse = { + routingKeys: RoutingKey[]; + _selfUrl?: string; +}; + +// @public (undocumented) +export type ListUserResponse = { + users: User[]; + _selfUrl?: string; +}; + +// @public (undocumented) +export type MessageType = + | 'CRITICAL' + | 'WARNING' + | 'ACKNOWLEDGEMENT' + | 'INFO' + | 'RECOVERY'; + +// @public (undocumented) +export type OnCall = { + team?: OnCallTeamResource; + oncallNow?: OnCallNowResource[]; +}; + +// @public (undocumented) +export type OnCallEscalationPolicyResource = { + name?: string; + slug?: string; +}; + +// @public (undocumented) +export type OnCallNowResource = { + escalationPolicy?: OnCallEscalationPolicyResource; + users?: OnCallUsersResource[]; +}; + +// @public (undocumented) +export type OnCallsResponse = { + teamsOnCall: OnCall[]; +}; + +// @public (undocumented) +export type OnCallTeamResource = { + name?: string; + slug?: string; +}; + +// @public (undocumented) +export type OnCallUser = { + username?: string; +}; + +// @public (undocumented) +export type OnCallUsersResource = { + onCalluser?: OnCallUser; +}; + +// @public (undocumented) +export type RequestOptions = { + method: string; + headers: HeadersInit; + body?: BodyInit; +}; + +// @public (undocumented) +export type RoutingKey = { + routingKey: string; + targets: RoutingKeyTarget[]; + isDefault: boolean; +}; + +// @public (undocumented) +export type RoutingKeyTarget = { + policyName: string; + policySlug: string; + _teamUrl: string; +}; + +// @public (undocumented) +export interface SplunkOnCallApi { + getEscalationPolicies(): Promise; + getIncidents(): Promise; + getOnCallUsers(): Promise; + getRoutingKeys(): Promise; + getTeams(): Promise; + getUsers(): Promise; + incidentAction(request: TriggerAlarmRequest): Promise; +} + // @public (undocumented) export const splunkOnCallApiRef: ApiRef; -// Warning: (ae-missing-release-tag) "SplunkOnCallClient" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export class SplunkOnCallClient implements SplunkOnCallApi { - // Warning: (ae-forgotten-export) The symbol "ClientApiConfig" needs to be exported by the entry point index.d.ts constructor(config: ClientApiConfig); // (undocumented) static fromConfig( configApi: ConfigApi, discoveryApi: DiscoveryApi, ): SplunkOnCallClient; - // Warning: (ae-forgotten-export) The symbol "EscalationPolicyInfo" needs to be exported by the entry point index.d.ts - // // (undocumented) getEscalationPolicies(): Promise; - // Warning: (ae-forgotten-export) The symbol "Incident" needs to be exported by the entry point index.d.ts - // // (undocumented) getIncidents(): Promise; - // Warning: (ae-forgotten-export) The symbol "OnCall" needs to be exported by the entry point index.d.ts - // // (undocumented) getOnCallUsers(): Promise; - // Warning: (ae-forgotten-export) The symbol "RoutingKey" needs to be exported by the entry point index.d.ts - // // (undocumented) getRoutingKeys(): Promise; - // Warning: (ae-forgotten-export) The symbol "Team" needs to be exported by the entry point index.d.ts - // // (undocumented) getTeams(): Promise; - // Warning: (ae-forgotten-export) The symbol "User" needs to be exported by the entry point index.d.ts - // // (undocumented) getUsers(): Promise; - // Warning: (ae-forgotten-export) The symbol "TriggerAlarmRequest" needs to be exported by the entry point index.d.ts - // // (undocumented) incidentAction({ routingKey, @@ -79,8 +224,6 @@ export class SplunkOnCallClient implements SplunkOnCallApi { }: TriggerAlarmRequest): Promise; } -// Warning: (ae-missing-release-tag) "SplunkOnCallPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export const SplunkOnCallPage: { ({ title, subtitle, pageTitle }: SplunkOnCallPageProps): JSX.Element; @@ -91,8 +234,13 @@ export const SplunkOnCallPage: { }; }; -// Warning: (ae-missing-release-tag) "splunkOnCallPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// +// @public (undocumented) +export type SplunkOnCallPageProps = { + title?: string; + subtitle?: string; + pageTitle?: string; +}; + // @public (undocumented) const splunkOnCallPlugin: BackstagePlugin< { @@ -104,12 +252,42 @@ const splunkOnCallPlugin: BackstagePlugin< export { splunkOnCallPlugin as plugin }; export { splunkOnCallPlugin }; -// 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 type Team = { + name?: string; + slug?: string; + memberCount?: number; + version?: number; + isDefaultTeam?: boolean; + _selfUrl?: string; + _policiesUrl?: string; + _membersUrl?: string; + _adminsUrl?: string; +}; + +// @public (undocumented) +export type TriggerAlarmRequest = { + routingKey?: string; + incidentType: MessageType; + incidentId?: string; + incidentDisplayName?: string; + incidentMessage?: string; + incidentStartTime?: number; +}; + // @public (undocumented) export class UnauthorizedError extends Error {} -// Warnings were encountered during analysis: -// -// src/plugin.d.ts:7:5 - (ae-forgotten-export) The symbol "SplunkOnCallPageProps" needs to be exported by the entry point index.d.ts +// @public (undocumented) +export type User = { + firstName?: string; + lastName?: string; + displayName?: string; + username?: string; + email?: string; + createdAt?: string; + passwordLastUpdated?: string; + verified?: boolean; + _selfUrl?: string; +}; ``` diff --git a/plugins/splunk-on-call/src/api/client.ts b/plugins/splunk-on-call/src/api/client.ts index 6c0ff9bdc4..aa655a4772 100644 --- a/plugins/splunk-on-call/src/api/client.ts +++ b/plugins/splunk-on-call/src/api/client.ts @@ -39,12 +39,15 @@ import { ConfigApi, } from '@backstage/core-plugin-api'; +/** @public */ export class UnauthorizedError extends Error {} +/** @public */ export const splunkOnCallApiRef = createApiRef({ id: 'plugin.splunk-on-call.api', }); +/** @public */ export class SplunkOnCallClient implements SplunkOnCallApi { static fromConfig(configApi: ConfigApi, discoveryApi: DiscoveryApi) { const eventsRestEndpoint: string | null = diff --git a/plugins/splunk-on-call/src/api/index.ts b/plugins/splunk-on-call/src/api/index.ts index 8b38168fc9..ecfb7acca7 100644 --- a/plugins/splunk-on-call/src/api/index.ts +++ b/plugins/splunk-on-call/src/api/index.ts @@ -19,4 +19,4 @@ export { splunkOnCallApiRef, UnauthorizedError, } from './client'; -export type { SplunkOnCallApi } from './types'; +export * from './types'; diff --git a/plugins/splunk-on-call/src/api/types.ts b/plugins/splunk-on-call/src/api/types.ts index 6a414d18bd..427eb8bbca 100644 --- a/plugins/splunk-on-call/src/api/types.ts +++ b/plugins/splunk-on-call/src/api/types.ts @@ -24,6 +24,7 @@ import { } from '../components/types'; import { DiscoveryApi } from '@backstage/core-plugin-api'; +/** @public */ export type MessageType = | 'CRITICAL' | 'WARNING' @@ -31,6 +32,7 @@ export type MessageType = | 'INFO' | 'RECOVERY'; +/** @public */ export type TriggerAlarmRequest = { routingKey?: string; incidentType: MessageType; @@ -40,6 +42,7 @@ export type TriggerAlarmRequest = { incidentStartTime?: number; }; +/** @public */ export interface SplunkOnCallApi { /** * Fetches a list of incidents @@ -77,33 +80,40 @@ export interface SplunkOnCallApi { getEscalationPolicies(): Promise; } +/** @public */ export type EscalationPolicyResponse = { policies: EscalationPolicyInfo[]; }; +/** @public */ export type ListUserResponse = { users: User[]; _selfUrl?: string; }; +/** @public */ export type ListRoutingKeyResponse = { routingKeys: RoutingKey[]; _selfUrl?: string; }; +/** @public */ export type IncidentsResponse = { incidents: Incident[]; }; +/** @public */ export type OnCallsResponse = { teamsOnCall: OnCall[]; }; +/** @public */ export type ClientApiConfig = { eventsRestEndpoint: string | null; discoveryApi: DiscoveryApi; }; +/** @public */ export type RequestOptions = { method: string; headers: HeadersInit; diff --git a/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.tsx b/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.tsx index 4f6bcd9a0e..d635f7328f 100644 --- a/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.tsx +++ b/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.tsx @@ -99,6 +99,7 @@ export const MissingEventsRestEndpoint = () => ( ); +/** @public */ export const isSplunkOnCallAvailable = (entity: Entity) => Boolean(entity.metadata.annotations?.[SPLUNK_ON_CALL_TEAM]) || Boolean(entity.metadata.annotations?.[SPLUNK_ON_CALL_ROUTING_KEY]); diff --git a/plugins/splunk-on-call/src/components/SplunkOnCallPage.tsx b/plugins/splunk-on-call/src/components/SplunkOnCallPage.tsx index 1f5bb49410..0c8b223857 100644 --- a/plugins/splunk-on-call/src/components/SplunkOnCallPage.tsx +++ b/plugins/splunk-on-call/src/components/SplunkOnCallPage.tsx @@ -31,6 +31,7 @@ const useStyles = makeStyles(() => ({ }, })); +/** @public */ export type SplunkOnCallPageProps = { title?: string; subtitle?: string; diff --git a/plugins/splunk-on-call/src/components/index.ts b/plugins/splunk-on-call/src/components/index.ts new file mode 100644 index 0000000000..47fd7fbf27 --- /dev/null +++ b/plugins/splunk-on-call/src/components/index.ts @@ -0,0 +1,20 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export type { SplunkOnCallPageProps } from './SplunkOnCallPage'; +export type { EntitySplunkOnCallCardProps } from './EntitySplunkOnCallCard'; +export { isSplunkOnCallAvailable } from './EntitySplunkOnCallCard'; +export * from './types'; diff --git a/plugins/splunk-on-call/src/components/types.ts b/plugins/splunk-on-call/src/components/types.ts index 0feefe8b03..7e83de84a7 100644 --- a/plugins/splunk-on-call/src/components/types.ts +++ b/plugins/splunk-on-call/src/components/types.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +/** @public */ export type Team = { name?: string; slug?: string; @@ -26,34 +27,41 @@ export type Team = { _adminsUrl?: string; }; +/** @public */ export type OnCall = { team?: OnCallTeamResource; oncallNow?: OnCallNowResource[]; }; +/** @public */ export type OnCallTeamResource = { name?: string; slug?: string; }; +/** @public */ export type OnCallNowResource = { escalationPolicy?: OnCallEscalationPolicyResource; users?: OnCallUsersResource[]; }; +/** @public */ export type OnCallEscalationPolicyResource = { name?: string; slug?: string; }; +/** @public */ export type OnCallUsersResource = { onCalluser?: OnCallUser; }; +/** @public */ export type OnCallUser = { username?: string; }; +/** @public */ export type User = { firstName?: string; lastName?: string; @@ -66,8 +74,10 @@ export type User = { _selfUrl?: string; }; +/** @public */ export type IncidentPhase = 'UNACKED' | 'ACKED' | 'RESOLVED'; +/** @public */ export type Incident = { incidentNumber?: string; startTime?: string; @@ -92,11 +102,13 @@ export type Incident = { incidentLink?: string; }; +/** @public */ export type EscalationPolicyInfo = { policy: EscalationPolicySummary; team?: EscalationPolicyTeam; }; +/** @public */ export type IncidentTransition = { name?: string; at?: string; @@ -107,23 +119,27 @@ export type IncidentTransition = { alertUrl?: string; }; +/** @public */ export type EscalationPolicySummary = { name: string; slug: string; _selfUrl: string; }; +/** @public */ export type EscalationPolicyTeam = { name: string; slug: string; }; +/** @public */ export type RoutingKey = { routingKey: string; targets: RoutingKeyTarget[]; isDefault: boolean; }; +/** @public */ export type RoutingKeyTarget = { policyName: string; policySlug: string; diff --git a/plugins/splunk-on-call/src/index.ts b/plugins/splunk-on-call/src/index.ts index 917106504b..285e6c8f89 100644 --- a/plugins/splunk-on-call/src/index.ts +++ b/plugins/splunk-on-call/src/index.ts @@ -26,9 +26,5 @@ export { splunkOnCallPlugin as plugin, SplunkOnCallPage, } from './plugin'; -export { isSplunkOnCallAvailable } from './components/EntitySplunkOnCallCard'; -export { - SplunkOnCallClient, - splunkOnCallApiRef, - UnauthorizedError, -} from './api/client'; +export * from './components'; +export * from './api'; diff --git a/plugins/splunk-on-call/src/plugin.ts b/plugins/splunk-on-call/src/plugin.ts index 2256b382ee..f1fa08bfcc 100644 --- a/plugins/splunk-on-call/src/plugin.ts +++ b/plugins/splunk-on-call/src/plugin.ts @@ -26,6 +26,7 @@ import { export const rootRouteRef = createRouteRef({ id: 'splunk-on-call' }); +/** @public */ export const splunkOnCallPlugin = createPlugin({ id: 'splunk-on-call', apis: [ @@ -41,6 +42,7 @@ export const splunkOnCallPlugin = createPlugin({ }, }); +/** @public */ export const SplunkOnCallPage = splunkOnCallPlugin.provide( createRoutableExtension({ name: 'SplunkOnCallPage', @@ -50,6 +52,7 @@ export const SplunkOnCallPage = splunkOnCallPlugin.provide( }), ); +/** @public */ export const EntitySplunkOnCallCard = splunkOnCallPlugin.provide( createComponentExtension({ name: 'EntitySplunkOnCallCard', diff --git a/scripts/api-extractor.ts b/scripts/api-extractor.ts index 98398ca5d9..4713d85487 100644 --- a/scripts/api-extractor.ts +++ b/scripts/api-extractor.ts @@ -231,7 +231,6 @@ const ALLOW_WARNINGS = [ 'plugins/newrelic-dashboard', 'plugins/pagerduty', 'plugins/search-backend-module-pg', - 'plugins/splunk-on-call', ]; async function resolvePackagePath(