huge work for nextcloud api
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.Model.Apps.FilesRetention;
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.OCS.APIs.Apps;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.Client.Apps
|
||||
{
|
||||
public class FilesRetentionClient : ClientBase
|
||||
{
|
||||
public FilesRetentionClient(NextcloudClient client) : base(client)
|
||||
{
|
||||
}
|
||||
|
||||
public Task<bool> CreateRetentionRule(RetentionRule rule)
|
||||
{
|
||||
var entry = rule.ToOcsData();
|
||||
return Client.Ocs.GetApi<OcsApiFilesRetention>().CreateRetentionRule(entry);
|
||||
}
|
||||
|
||||
public Task<bool> DeleteRetentionRule(int ruleID)
|
||||
{
|
||||
return Client.Ocs.GetApi<OcsApiFilesRetention>().DeleteRetentionRule(ruleID);
|
||||
}
|
||||
|
||||
public async Task<RetentionRule[]?> GetRetentionRules()
|
||||
{
|
||||
var api = Client.Ocs.GetApi<OcsApiFilesRetention>();
|
||||
var response = await api.GetRetentionRules();
|
||||
|
||||
if (response?.Data is not null)
|
||||
{
|
||||
var rules = new List<RetentionRule>();
|
||||
|
||||
foreach (var entry in response.Data)
|
||||
rules.Add(new RetentionRule(entry));
|
||||
|
||||
return rules.ToArray();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user