Extract interface

Signed-off-by: Julio Zynger <julio.zynger@soundcloud.com>
This commit is contained in:
Julio Zynger
2022-03-04 10:09:44 +01:00
committed by Fredrik Adelöw
parent 7235b16054
commit 9e04715967
2 changed files with 33 additions and 3 deletions
+31 -1
View File
@@ -33,7 +33,37 @@ type PeriskopInstance = {
*
* @public
*/
export class PeriskopApi {
export interface PeriskopApi {
/**
* Returns the list of registered Periskop instance names.
*/
getInstanceNames(): string[];
/**
* For the given instance and service, returns the URL pointing to the specific error instance occurrence.
* Note: This method might point to an external route.
*/
getErrorInstanceUrl(
instanceName: string,
serviceName: string,
error: AggregatedError,
): string;
/**
* Fetches all errors for the given service from the specified Periskop instance, given its name.
*/
getErrors(
instanceName: string,
serviceName: string,
): Promise<AggregatedError[] | NotFoundInInstance>;
}
/**
* API implementation to interact with Periskop's backends.
*
* @public
*/
export class PeriskopClient implements PeriskopApi {
private readonly discoveryApi: DiscoveryApi;
private readonly instances: PeriskopInstance[];
+2 -2
View File
@@ -21,7 +21,7 @@ import {
createPlugin,
createApiRef,
} from '@backstage/core-plugin-api';
import { PeriskopApi } from './api';
import { PeriskopApi, PeriskopClient } from './api';
/**
* @public
@@ -40,7 +40,7 @@ export const periskopPlugin = createPlugin({
api: periskopApiRef,
deps: { configApi: configApiRef, discoveryApi: discoveryApiRef },
factory: ({ configApi, discoveryApi }) =>
new PeriskopApi({ configApi, discoveryApi }),
new PeriskopClient({ configApi, discoveryApi }),
}),
],
});