introduce a very simple Nextcloud API
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using Newtonsoft.Json;
|
||||
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.Model
|
||||
{
|
||||
public class NextcloudLogin
|
||||
{
|
||||
/// <summary>
|
||||
/// The server url the login credentials are for.
|
||||
/// </summary>
|
||||
public string? Server { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The login name (username or password) used for the login.
|
||||
/// </summary>
|
||||
public string? LoginName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The app password that has been generated.
|
||||
/// </summary>
|
||||
public string? AppPassword { get; set; }
|
||||
|
||||
public NextcloudLogin()
|
||||
{
|
||||
}
|
||||
|
||||
public NextcloudLogin(OcsResponseLoginFlowV2Credentials response)
|
||||
{
|
||||
Server = response.Server;
|
||||
LoginName = response.LoginName;
|
||||
AppPassword = response.AppPassword;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.Model
|
||||
{
|
||||
public class UserBackendCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines if the display name can be changed.
|
||||
/// </summary>
|
||||
public bool SetDisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines if the password can be changed.
|
||||
/// </summary>
|
||||
public bool SetPassword { get; set; }
|
||||
}
|
||||
}
|
||||
131
Pilz.Networking.CloudProviders.Nextcloud/Model/UserInfo.cs
Normal file
131
Pilz.Networking.CloudProviders.Nextcloud/Model/UserInfo.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
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.Model
|
||||
{
|
||||
public class UserInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines if the user is enabled.
|
||||
/// </summary>
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The location of the user's storage directory.
|
||||
/// </summary>
|
||||
public string? StorageLocation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The uniquie user id that infos are for.
|
||||
/// </summary>
|
||||
public string? ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The last time when the user has logged in to its account.
|
||||
/// </summary>
|
||||
public DateTime LastLogin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The backend of the user. Common values are "Database" or "LDAP".
|
||||
/// </summary>
|
||||
public string? Backend { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Email address of the user.
|
||||
/// </summary>
|
||||
public string? Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The displayname of the user.
|
||||
/// </summary>
|
||||
public string? Displayname { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The displayname of the user.
|
||||
/// </summary>
|
||||
public string? Displayname2 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The phone number of the user.
|
||||
/// </summary>
|
||||
public string? Phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The address of the user.
|
||||
/// </summary>
|
||||
public string? Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Website of the user.
|
||||
/// </summary>
|
||||
public string? Website { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The twitter profile name of the user.
|
||||
/// </summary>
|
||||
public string? Twitter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines the groups the user is member of.
|
||||
/// </summary>
|
||||
public string[] Groups { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The configured language of the user.
|
||||
/// </summary>
|
||||
public string? Language { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The configured location of the user.
|
||||
/// </summary>
|
||||
public string? Locale { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Quota informations for the user.
|
||||
/// </summary>
|
||||
public UserQuota Quota { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Backend capabilities of the user.
|
||||
/// </summary>
|
||||
public UserBackendCapabilities BackendCapabilities { get; } = new();
|
||||
|
||||
public UserInfo(OcsResponseDataUser responseData)
|
||||
{
|
||||
Enabled = Convert.ToBoolean(responseData.Enabled);
|
||||
StorageLocation = responseData.StorageLocation;
|
||||
ID = responseData.ID;
|
||||
LastLogin = Convert.ToDateTime(responseData.LastLogin);
|
||||
Backend = responseData.Backend;
|
||||
Email = responseData.Email;
|
||||
Displayname = responseData.Displayname;
|
||||
Displayname2 = responseData.Displayname2;
|
||||
Phone = responseData.Phone;
|
||||
Address = responseData.Address;
|
||||
Website = responseData.Website;
|
||||
Twitter = responseData.Twitter;
|
||||
Groups = responseData.Groups ?? Array.Empty<string>();
|
||||
Language = responseData.Language;
|
||||
Locale = responseData.Locale;
|
||||
|
||||
if (responseData.Quota != null)
|
||||
{
|
||||
Quota.Free = responseData.Quota.Free ?? 0;
|
||||
Quota.Used = responseData.Quota.Used ?? 0;
|
||||
Quota.Total = responseData.Quota.Total ?? 0;
|
||||
Quota.Relative = responseData.Quota.Relative ?? 0.0F;
|
||||
Quota.Quota = responseData.Quota.Quota ?? 0;
|
||||
}
|
||||
|
||||
if (responseData.BackendCapabilities != null)
|
||||
{
|
||||
BackendCapabilities.SetDisplayName = Convert.ToBoolean(responseData.BackendCapabilities.SetDisplayName);
|
||||
BackendCapabilities.SetPassword = Convert.ToBoolean(responseData.BackendCapabilities.SetPassword);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Pilz.Networking.CloudProviders.Nextcloud/Model/UserQuota.cs
Normal file
37
Pilz.Networking.CloudProviders.Nextcloud/Model/UserQuota.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Networking.CloudProviders.Nextcloud.Model
|
||||
{
|
||||
public class UserQuota
|
||||
{
|
||||
/// <summary>
|
||||
/// Amount of free bytes left.
|
||||
/// </summary>
|
||||
public ulong Free { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Amount of already used bytes.
|
||||
/// </summary>
|
||||
public ulong Used { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total amount of all bytes (free + used).
|
||||
/// </summary>
|
||||
public ulong Total { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Relative amount of used quota in percent.
|
||||
/// </summary>
|
||||
public float Relative { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total amount of bytes available.
|
||||
/// </summary>
|
||||
public ulong Quota { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user