PR Feedback

Signed-off-by: Wesley Pattison <wesley.pattison@friss.com>
This commit is contained in:
Wesley Pattison
2022-10-19 12:04:01 +02:00
parent 7943f0efc9
commit d66efa6aa9
3 changed files with 37 additions and 53 deletions
@@ -35,56 +35,44 @@ export class AzureSitesApiBackendClient implements AzureSitesApi {
}
async stop(request: AzureSiteStartStopRequest): Promise<void> {
try {
const url = `${await this.discoveryApi.getBaseUrl('azure-functions')}/${
request.subscription
}/${request.resourceGroup}/${request.name}/stop`;
const { token: accessToken } = await this.identityApi.getCredentials();
await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(accessToken && { Authorization: `Bearer ${accessToken}` }),
},
});
} catch (e: any) {
throw new Error(e);
}
const url = `${await this.discoveryApi.getBaseUrl('azure-functions')}/${
request.subscription
}/${request.resourceGroup}/${request.name}/stop`;
const { token: accessToken } = await this.identityApi.getCredentials();
await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(accessToken && { Authorization: `Bearer ${accessToken}` }),
},
});
}
async start(request: AzureSiteStartStopRequest): Promise<void> {
try {
const url = `${await this.discoveryApi.getBaseUrl('azure-functions')}/${
request.subscription
}/${request.resourceGroup}/${request.name}/start`;
const { token: accessToken } = await this.identityApi.getCredentials();
await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(accessToken && { Authorization: `Bearer ${accessToken}` }),
},
});
} catch (e: any) {
throw new Error(e);
}
const url = `${await this.discoveryApi.getBaseUrl('azure-functions')}/${
request.subscription
}/${request.resourceGroup}/${request.name}/start`;
const { token: accessToken } = await this.identityApi.getCredentials();
await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...(accessToken && { Authorization: `Bearer ${accessToken}` }),
},
});
}
async list(request: AzureSiteListRequest): Promise<AzureSiteListResponse> {
try {
const url = `${await this.discoveryApi.getBaseUrl('azure-sites')}/list/${
request.name
}`;
const { token: accessToken } = await this.identityApi.getCredentials();
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
...(accessToken && { Authorization: `Bearer ${accessToken}` }),
},
});
return await response.json();
} catch (e: any) {
throw new Error(e);
}
const url = `${await this.discoveryApi.getBaseUrl('azure-sites')}/list/${
request.name
}`;
const { token: accessToken } = await this.identityApi.getCredentials();
const response = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
...(accessToken && { Authorization: `Bearer ${accessToken}` }),
},
});
return await response.json();
}
}
+3 -4
View File
@@ -24,14 +24,13 @@ import {
} from '@backstage/core-plugin-api';
import { azureSiteApiRef, AzureSitesApiBackendClient } from './api';
/** @public */
export const entityContentRouteRef = createRouteRef({
id: 'Azure Entity Content',
const entityContentRouteRef = createRouteRef({
id: 'Azure Sites Entity Content',
});
/** @public */
export const azureSitesPlugin = createPlugin({
id: 'azureFunctions',
id: 'azureSites',
apis: [
createApiFactory({
api: azureSiteApiRef,