mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.7 KiB
49 lines
1.7 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using Squidex.Domain.Apps.Entities.Backup;
|
|
using Squidex.Shared;
|
|
using Squidex.Web;
|
|
|
|
namespace Squidex.Areas.Api.Controllers.Backups.Models
|
|
{
|
|
public sealed class BackupJobsDto : Resource
|
|
{
|
|
/// <summary>
|
|
/// The backups.
|
|
/// </summary>
|
|
[Required]
|
|
public BackupJobDto[] Items { get; set; }
|
|
|
|
public static BackupJobsDto FromBackups(IEnumerable<IBackupJob> backups, ApiController controller, string app)
|
|
{
|
|
var result = new BackupJobsDto
|
|
{
|
|
Items = backups.Select(x => BackupJobDto.FromBackup(x, controller, app)).ToArray()
|
|
};
|
|
|
|
return CreateLinks(result, controller, app);
|
|
}
|
|
|
|
private static BackupJobsDto CreateLinks(BackupJobsDto result, ApiController controller, string app)
|
|
{
|
|
var values = new { app };
|
|
|
|
result.AddSelfLink(controller.Url<BackupsController>(x => nameof(x.GetBackups), values));
|
|
|
|
if (controller.HasPermission(Permissions.AppBackupsCreate, app))
|
|
{
|
|
result.AddPostLink("create", controller.Url<BackupsController>(x => nameof(x.PostBackup), values));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|