* Adding migration to update the default GUID value of created packages * Updating the GUID if it is the default value when a package is saved * Adding PackageDefinitionViewModel for representing a package * Adding a mapping for package representation * Adding PackageControllerBase, GetAllCreated and GetEmpty endpoints * Adding GetCreatedByKey endpoint * Adding GetByKey implementation for created packages * Include MapAll comment * Adding Download package endpoint * Saving created package endpoint * Adding a factory to create a PackageDefinition from view model * Cleanup * Fix error message * Check for duplicate package name * Remove commented out DuplicateNameException * Moving created packages to /created folder/base * Implement delete endpoint * Update OpenApi.json * Fix package route * Fix OpenApi.json * Add Ok() around the result * Create PackageBuilderExtensions * Adding suppression changes * Cleanup * Use ProblemDetailsBuilder * Extract collecting installed packages from package migration plans into its own method * Use GetInstalledPackagesFromMigrationPlans to return all migration statuses * Add Status to DictionaryControllerBase ProblemDetails * Implement RunMigrationPackageController * Adding more information to the log message * Update OpenApi.json * Change param name * Fix OpenApi.json * Fix response type for Log viewer endpoint * Remove EmptyPackageController * Rename to RunPendingPackageMigrations * Introduce new PackageOperationStatus * Making methods async and introducing new Create, Update and Delete methods * Fix async calls * Fix Mapper - multiple enumeration and cleanup * Creating special action models * Fixing the factory with new models changes * Service implementation changes * Removing SaveCreatedPackageController as the functionality is split between Create and UpdateCreatedPackageController * Utilize the new DeleteCreatedPackageAsync * Refactor DownloadCreatedPackageController as some responsibility is moved to the service * Refactor PackagingService to use auditService * Refactor PackagingService to use skip/take * Refactor services to return pagedmodel * Refactor controller to use new return value * update OpenApi.json --------- Co-authored-by: Zeegaan <nge@umbraco.dk>
41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Packaging;
|
|
using Umbraco.Cms.Core.Security;
|
|
using Umbraco.Cms.Core.Services;
|
|
using Umbraco.Cms.Core.Services.OperationStatus;
|
|
|
|
namespace Umbraco.Cms.Api.Management.Controllers.Package.Created;
|
|
|
|
public class DeleteCreatedPackageController : CreatedPackageControllerBase
|
|
{
|
|
private readonly IPackagingService _packagingService;
|
|
private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor;
|
|
|
|
public DeleteCreatedPackageController(IPackagingService packagingService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor)
|
|
{
|
|
_packagingService = packagingService;
|
|
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deletes a package with a given key.
|
|
/// </summary>
|
|
/// <param name="key">The key of the package.</param>
|
|
/// <returns>The result of the deletion.</returns>
|
|
[HttpDelete("{key:guid}")]
|
|
[MapToApiVersion("1.0")]
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
public async Task<IActionResult> Delete(Guid key)
|
|
{
|
|
Attempt<PackageDefinition?, PackageOperationStatus> result =
|
|
await _packagingService.DeleteCreatedPackageAsync(key, CurrentUserId(_backOfficeSecurityAccessor));
|
|
|
|
return result.Success
|
|
? Ok()
|
|
: PackageOperationStatusResult(result.Status);
|
|
}
|
|
}
|