mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-13 05:15:30 +00:00
RP doesn't support stored procedure, trigger, and UDF operations for Gremlin API so we have to use SDK for now.
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { AuthType } from "../../AuthType";
|
|
import { DefaultAccountExperienceType } from "../../DefaultAccountExperienceType";
|
|
import { client } from "../CosmosClient";
|
|
import { deleteSqlStoredProcedure } from "../../Utils/arm/generatedClients/2020-04-01/sqlResources";
|
|
import { handleError } from "../ErrorHandlingUtils";
|
|
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
|
import { userContext } from "../../UserContext";
|
|
|
|
export async function deleteStoredProcedure(
|
|
databaseId: string,
|
|
collectionId: string,
|
|
storedProcedureId: string
|
|
): Promise<void> {
|
|
const clearMessage = logConsoleProgress(`Deleting stored procedure ${storedProcedureId}`);
|
|
try {
|
|
if (
|
|
window.authType === AuthType.AAD &&
|
|
!userContext.useSDKOperations &&
|
|
userContext.defaultExperience === DefaultAccountExperienceType.DocumentDB
|
|
) {
|
|
await deleteSqlStoredProcedure(
|
|
userContext.subscriptionId,
|
|
userContext.resourceGroup,
|
|
userContext.databaseAccount.name,
|
|
databaseId,
|
|
collectionId,
|
|
storedProcedureId
|
|
);
|
|
} else {
|
|
await client()
|
|
.database(databaseId)
|
|
.container(collectionId)
|
|
.scripts.storedProcedure(storedProcedureId)
|
|
.delete();
|
|
}
|
|
} catch (error) {
|
|
handleError(error, `Error while deleting stored procedure ${storedProcedureId}`, "DeleteStoredProcedure");
|
|
throw error;
|
|
} finally {
|
|
clearMessage();
|
|
}
|
|
}
|