Files
Umbraco-CMS/src/Umbraco.Cms.Api.Management/Controllers/Package/AllMigrationStatusPackageController.cs
Elitsa Marinovska c2ecc8dc33 New Backoffice: Package controller (#13578)
* 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>
2023-02-23 14:36:21 +01:00

45 lines
1.9 KiB
C#

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
using Umbraco.Cms.Api.Management.ViewModels.Package;
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Core.Packaging;
using Umbraco.Cms.Core.Services;
using Umbraco.New.Cms.Core.Models;
namespace Umbraco.Cms.Api.Management.Controllers.Package;
public class AllMigrationStatusPackageController : PackageControllerBase
{
private readonly IPackagingService _packagingService;
private readonly IUmbracoMapper _umbracoMapper;
public AllMigrationStatusPackageController(IPackagingService packagingService, IUmbracoMapper umbracoMapper)
{
_packagingService = packagingService;
_umbracoMapper = umbracoMapper;
}
/// <summary>
/// Gets a paginated list of the migration status of each installed package.
/// </summary>
/// <param name="skip">The amount of items to skip.</param>
/// <param name="take">The amount of items to take.</param>
/// <returns>The paged result of the installed packages migration status.</returns>
[HttpGet("migration-status")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(PagedViewModel<PackageMigrationStatusViewModel>), StatusCodes.Status200OK)]
public async Task<ActionResult<PagedViewModel<PackageMigrationStatusViewModel>>> AllMigrationStatuses(int skip = 0, int take = 100)
{
PagedModel<InstalledPackage> migrationPlans = await _packagingService.GetInstalledPackagesFromMigrationPlansAsync(skip, take);
IEnumerable<PackageMigrationStatusViewModel> viewModels = _umbracoMapper.MapEnumerable<InstalledPackage, PackageMigrationStatusViewModel>(migrationPlans.Items);
return Ok(new PagedViewModel<PackageMigrationStatusViewModel>()
{
Total = migrationPlans.Total,
Items = viewModels,
});
}
}