Reorganized the module structure.
This commit is contained in:
32
src/graph/app.js
Normal file
32
src/graph/app.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Get an Azure application by its display name.
|
||||
*
|
||||
* @param { Object } client
|
||||
* @param { string } appName
|
||||
* @returns
|
||||
*/
|
||||
export async function getApp(client, appName) {
|
||||
const result = await client
|
||||
.api("/applications")
|
||||
.filter(`displayName eq '${appName}'`)
|
||||
.get();
|
||||
|
||||
// Return the first application found or null if none exists
|
||||
return result.value.length > 0 ? result.value[0] : null;
|
||||
}
|
||||
|
||||
export async function createApp(client, appName) {
|
||||
const app = await client.api("/applications").post({
|
||||
displayName: appName,
|
||||
});
|
||||
|
||||
if (!app || !app.appId) {
|
||||
throw new Error("Failed to create application");
|
||||
}
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
export async function deleteApp(client, appObjectId) {
|
||||
await client.api(`/applications/${appObjectId}`).delete();
|
||||
}
|
||||
Reference in New Issue
Block a user