re-organize Nextcloud project structure
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.OCS.Data.Apps.FileRetention;
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses;
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses.Apps.FilesRetention;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.APIs.Apps
|
||||
{
|
||||
public class OcsApiFilesRetention : OcsApiBase
|
||||
{
|
||||
public static readonly OcsApiUrlPath OCS_FILE_RETENTION_RULES = new("/ocs/v2.php/apps/files_retention/api/v1/retentions");
|
||||
public static readonly OcsApiUrlPath OCS_FILE_RETENTION_RULE = new("/ocs/v2.php/apps/files_retention/api/v1/retentions/{0}");
|
||||
|
||||
public OcsApiFilesRetention(OcsApi manager) : base(manager)
|
||||
{
|
||||
}
|
||||
|
||||
public bool CreateRetentionRule(OcsDataRetentionRule rule)
|
||||
{
|
||||
var response = Manager.MakeRequest(HttpMethod.Post, OCS_FILE_RETENTION_RULES, content: rule);
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
|
||||
public bool DeleteRetentionRule(int ruleID)
|
||||
{
|
||||
var response = Manager.MakeRequest(HttpMethod.Delete, OCS_FILE_RETENTION_RULE.FillParameters(ruleID));
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
|
||||
public OcsResponseRetention? GetRetentionRules()
|
||||
{
|
||||
return Manager.MakeRequestOcs<OcsResponseRetention>(HttpMethod.Get, OCS_FILE_RETENTION_RULES);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses.Cloud;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.APIs
|
||||
{
|
||||
public class OcsApiCloud : OcsApiBase
|
||||
{
|
||||
public readonly static OcsApiUrlPath OCS_CLOUD_USER_METADATA = new("/ocs/v1.php/cloud/users/{0}");
|
||||
|
||||
public OcsApiCloud(OcsApi manager) : base(manager)
|
||||
{
|
||||
}
|
||||
|
||||
public OcsResponseUser? GetUserMeta(string username)
|
||||
{
|
||||
return Manager.MakeRequestOcs<OcsResponseUser>(HttpMethod.Get, OCS_CLOUD_USER_METADATA.FillParameters(username));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.APIs
|
||||
{
|
||||
public class OcsApiCore : OcsApiBase
|
||||
{
|
||||
public static readonly OcsApiUrlPath OCS_CORE_APPPASSWORD = "/ocs/v2.php/core/apppassword";
|
||||
|
||||
public OcsApiCore(OcsApi manager) : base(manager)
|
||||
{
|
||||
}
|
||||
|
||||
public bool DeleteAppPassword()
|
||||
{
|
||||
using var msg = Manager.MakeRequest(HttpMethod.Delete, OCS_CORE_APPPASSWORD);
|
||||
return msg != null && msg.IsSuccessStatusCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses.LoginFlowV2;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.APIs
|
||||
{
|
||||
public class OcsApiLoginFlowV2 : OcsApiBase
|
||||
{
|
||||
private const string OCS_LOGIN_INIT = "/index.php/login/v2";
|
||||
|
||||
public OcsApiLoginFlowV2(OcsApi manager) : base(manager)
|
||||
{
|
||||
}
|
||||
|
||||
public OcsResponseLoginFlowV2? Init(string url)
|
||||
{
|
||||
return Manager.MakeRequest<OcsResponseLoginFlowV2>(HttpMethod.Get, url + OCS_LOGIN_INIT);
|
||||
}
|
||||
|
||||
public OcsResponseLoginFlowV2Credentials? Poll(OcsResponseLoginFlowV2.PollData poll)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(poll?.Endpoint);
|
||||
ArgumentNullException.ThrowIfNull(poll?.Token);
|
||||
|
||||
return Manager.MakeRequest<OcsResponseLoginFlowV2Credentials?>(HttpMethod.Get, poll.Endpoint,
|
||||
parameters: new Dictionary<string, string>
|
||||
{
|
||||
{ "token", poll.Token }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.Data.Apps.FileRetention
|
||||
{
|
||||
public class OcsDataRetentionRule : OcsData
|
||||
{
|
||||
|
||||
[JsonProperty("tagid")]
|
||||
public int? TagID { get; set; }
|
||||
|
||||
[JsonProperty("timeunit")]
|
||||
public int? TimeUnit { get; set; }
|
||||
|
||||
[JsonProperty("timeamount")]
|
||||
public int? TimeAmount { get; set; }
|
||||
|
||||
[JsonProperty("timeafter")]
|
||||
public int? TimeAfter { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,12 @@ using System.Net.Http.Headers;
|
||||
using Newtonsoft.Json;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.OCS.APIs;
|
||||
using System.Net.Sockets;
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.OCS.Data;
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses;
|
||||
using System.Xml.Linq;
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.Client.Cloud;
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.Client.Core;
|
||||
using Pilz.Networking.CloudProviders.Nextcloud.Client.LoginFlowV2;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.APIs
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS
|
||||
{
|
||||
public abstract class OcsApiBase
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.Data
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS
|
||||
{
|
||||
public class OcsData
|
||||
{
|
||||
@@ -1,30 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses.Apps.FilesRetention
|
||||
{
|
||||
public class OcsResponseDataEntryRetention : OcsResponseDataEntry
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public int? ID { get; set; }
|
||||
|
||||
[JsonProperty("tagid")]
|
||||
public int? TagID { get; set; }
|
||||
|
||||
[JsonProperty("timeunit")]
|
||||
public int? TimeUnit { get; set; }
|
||||
|
||||
[JsonProperty("timeamount")]
|
||||
public int? TimeAmount { get; set; }
|
||||
|
||||
[JsonProperty("timeafter")]
|
||||
public int? TimeAfter { get; set; }
|
||||
|
||||
[JsonProperty("hasJob")]
|
||||
public bool? HasJob { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses.Apps.FilesRetention
|
||||
{
|
||||
public class OcsResponseRetention : OcsResponse<OcsResponseDataArray<OcsResponseDataEntryRetention>>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses.Cloud
|
||||
{
|
||||
public class OcsResponseDataUser : OcsResponseData
|
||||
{
|
||||
public class ResponseQuota
|
||||
{
|
||||
[JsonProperty("free")]
|
||||
public long? Free { get; set; }
|
||||
|
||||
[JsonProperty("used")]
|
||||
public long? Used { get; set; }
|
||||
|
||||
[JsonProperty("total")]
|
||||
public long? Total { get; set; }
|
||||
|
||||
[JsonProperty("relative")]
|
||||
public float? Relative { get; set; }
|
||||
|
||||
[JsonProperty("quota")]
|
||||
public long? Quota { get; set; }
|
||||
}
|
||||
|
||||
public class ResponseBackendCapabilities
|
||||
{
|
||||
[JsonProperty("setDisplayName")]
|
||||
public bool? SetDisplayName { get; set; }
|
||||
|
||||
[JsonProperty("setPassword")]
|
||||
public bool? SetPassword { get; set; }
|
||||
}
|
||||
|
||||
[JsonProperty("enabled")]
|
||||
public bool? Enabled { get; set; }
|
||||
|
||||
[JsonProperty("storageLocation")]
|
||||
public string? StorageLocation { get; set; }
|
||||
|
||||
[JsonProperty("id")]
|
||||
public string? ID { get; set; }
|
||||
|
||||
[JsonProperty("lastLogin")]
|
||||
public long? LastLogin { get; set; }
|
||||
|
||||
[JsonProperty("backend")]
|
||||
public string? Backend { get; set; }
|
||||
|
||||
[JsonProperty("quota")]
|
||||
public ResponseQuota? Quota { get; set; }
|
||||
|
||||
[JsonProperty("email")]
|
||||
public string? Email { get; set; }
|
||||
|
||||
[JsonProperty("displayname")]
|
||||
public string? Displayname { get; set; }
|
||||
|
||||
[JsonProperty("display-name")]
|
||||
public string? Displayname2 { get; set; }
|
||||
|
||||
[JsonProperty("phone")]
|
||||
public string? Phone { get; set; }
|
||||
|
||||
[JsonProperty("address")]
|
||||
public string? Address { get; set; }
|
||||
|
||||
[JsonProperty("website")]
|
||||
public string? Website { get; set; }
|
||||
|
||||
[JsonProperty("twitter")]
|
||||
public string? Twitter { get; set; }
|
||||
|
||||
[JsonProperty("groups")]
|
||||
public string[]? Groups { get; set; }
|
||||
|
||||
[JsonProperty("language")]
|
||||
public string? Language { get; set; }
|
||||
|
||||
[JsonProperty("locale")]
|
||||
public string? Locale { get; set; }
|
||||
|
||||
[JsonProperty("backendCapabilities")]
|
||||
public ResponseBackendCapabilities? BackendCapabilities { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses.Cloud
|
||||
{
|
||||
public class OcsResponseUser : OcsResponse<OcsResponseDataUser>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses.LoginFlowV2
|
||||
{
|
||||
public class OcsResponseLoginFlowV2
|
||||
{
|
||||
public class PollData
|
||||
{
|
||||
/// <summary>
|
||||
/// The login token that has been created for the login process.
|
||||
/// It can be used to poll the login state.
|
||||
/// </summary>
|
||||
[JsonProperty("token")]
|
||||
public string? Token { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("endpoint")]
|
||||
public string? Endpoint { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonProperty("poll")]
|
||||
public PollData? Poll { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The temporary login url that should be used for login.
|
||||
/// </summary>
|
||||
[JsonProperty("login")]
|
||||
public string? LoginUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.OCS.Responses.LoginFlowV2
|
||||
{
|
||||
public class OcsResponseLoginFlowV2Credentials
|
||||
{
|
||||
/// <summary>
|
||||
/// The server url the login credentials are for.
|
||||
/// </summary>
|
||||
[JsonProperty("server")]
|
||||
public string? Server { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The login name (username or password) used for the login.
|
||||
/// </summary>
|
||||
[JsonProperty("loginName")]
|
||||
public string? LoginName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The app password that has been generated.
|
||||
/// </summary>
|
||||
[JsonProperty("appPassword")]
|
||||
public string? AppPassword { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user