add delete migration method in migration list and details pages (#22243)

* add delete migraiton, fix stale token detection

* address pr comments, fix api error response format
This commit is contained in:
brian-harris
2023-03-09 13:52:48 -08:00
committed by GitHub
parent 12a5bd0ef2
commit 39f90afe6c
16 changed files with 229 additions and 77 deletions

View File

@@ -286,7 +286,11 @@ export async function getVMInstanceView(sqlVm: SqlVMServer, account: azdata.Acco
const response = await api.makeAzureRestRequest(account, subscription, path, azurecore.HttpRequestMethod.GET, undefined, true, host);
if (response.errors.length > 0) {
throw new Error(response.errors.toString());
const message = response.errors
.map(err => err.message)
.join(', ');
throw new Error(message);
}
return response.response.data;
@@ -299,7 +303,11 @@ export async function getAzureResourceGivenId(account: azdata.Account, subscript
const response = await api.makeAzureRestRequest(account, subscription, path, azurecore.HttpRequestMethod.GET, undefined, true, host);
if (response.errors.length > 0) {
throw new Error(response.errors.toString());
const message = response.errors
.map(err => err.message)
.join(', ');
throw new Error(message);
}
return response.response.data;
@@ -620,6 +628,19 @@ export async function stopMigration(account: azdata.Account, subscription: Subsc
}
}
export async function deleteMigration(account: azdata.Account, subscription: Subscription, migrationId: string): Promise<void> {
const api = await getAzureCoreAPI();
const path = encodeURI(`${migrationId}?api-version=${DMSV2_API_VERSION}`);
const host = api.getProviderMetadataForAccount(account).settings.armResource?.endpoint;
const response = await api.makeAzureRestRequest(account, subscription, path, azurecore.HttpRequestMethod.DELETE, undefined, true, host);
if (response.errors.length > 0) {
const message = response.errors
.map(err => err.message)
.join(', ');
throw new Error(message);
}
}
export async function getLocationDisplayName(location: string): Promise<string> {
const api = await getAzureCoreAPI();
return api.getRegionDisplayName(location);