@spacelift-io/backstage-integration-frontend
Version:
Backstage plugin for integrating Spacelift.io with Backstage
35 lines (32 loc) • 1.01 kB
JavaScript
import { createApiRef } from '@backstage/core-plugin-api';
const spaceliftApiRef = createApiRef({
id: "plugin.spacelift.io.service"
});
class SpaceliftApi {
constructor(discoveryApi, fetchApi) {
this.discoveryApi = discoveryApi;
this.fetchApi = fetchApi;
}
async getStacks() {
const url = await this.discoveryApi.getBaseUrl("spacelift-io");
const response = await this.fetchApi.fetch(`${url}/stacks`);
if (!response.ok) {
const { error } = await response.json();
throw new Error(error);
}
return response.json();
}
async triggerRun(stackId) {
const url = await this.discoveryApi.getBaseUrl("spacelift-io");
const response = await this.fetchApi.fetch(`${url}/stacks/${stackId}/trigger`, {
method: "POST"
});
if (!response.ok) {
const { error } = await response.json();
throw new Error(error);
}
return response.json();
}
}
export { SpaceliftApi, spaceliftApiRef };
//# sourceMappingURL=SpaceliftApiClient.esm.js.map