-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from j4587698/feat-storage
feat: 增加存储相关操作
- Loading branch information
Showing
4 changed files
with
142 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using AListSdkSharp.Vo; | ||
using Flurl.Http; | ||
|
||
namespace AListSdkSharp.Api | ||
{ | ||
public class Storage | ||
{ | ||
private readonly Uri _baseUri; | ||
|
||
public Storage(string baseUrl) | ||
{ | ||
_baseUri = new Uri(baseUrl); | ||
} | ||
|
||
/// <summary> | ||
/// 获取所有存储列表 | ||
/// </summary> | ||
/// <param name="token"></param> | ||
/// <param name="page">页码,默认为null</param> | ||
/// <param name="prePage">每页条数,默认为null</param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public Task<StorageListOut> List(string token, int? page = null, int? prePage = null, CancellationToken cancellationToken = default) | ||
{ | ||
return new Uri(_baseUri, $"/api/admin/storage/list?page={page}&prePage={prePage}") | ||
.WithHeader("Authorization", token) | ||
.GetJsonAsync<StorageListOut>(cancellationToken: cancellationToken); | ||
} | ||
|
||
/// <summary> | ||
/// 启用存储 | ||
/// </summary> | ||
/// <param name="token"></param> | ||
/// <param name="id">存储id,从list中获取</param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public Task<Base> Enable(string token, int id, CancellationToken cancellationToken = default) | ||
{ | ||
return new Uri(_baseUri, $"/api/admin/storage/enable?id={id}") | ||
.WithHeader("Authorization", token) | ||
.PostAsync(cancellationToken: cancellationToken) | ||
.ReceiveJson<Base>(); | ||
} | ||
|
||
/// <summary> | ||
/// 禁用存储 | ||
/// </summary> | ||
/// <param name="token"></param> | ||
/// <param name="id">存储id,从list中获取</param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
public Task<Base> Disable(string token, int id, CancellationToken cancellationToken = default) | ||
{ | ||
return new Uri(_baseUri, $"/api/admin/storage/disable?id={id}") | ||
.WithHeader("Authorization", token) | ||
.PostAsync(cancellationToken: cancellationToken) | ||
.ReceiveJson<Base>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace AListSdkSharp.Vo | ||
{ | ||
public class StorageListOut: Base | ||
{ | ||
public StorageListOutData Data { get; set; } | ||
|
||
public class StorageListOutData | ||
{ | ||
public List<StorageListOutContent> Content { get; set; } | ||
|
||
public int Total { get; set; } | ||
} | ||
|
||
public class StorageListOutContent | ||
{ | ||
public int Id { get; set; } | ||
|
||
[JsonPropertyName("mount_path")] | ||
public string MountPath { get; set; } | ||
|
||
public int Order { get; set; } | ||
|
||
public string Driver { get; set; } | ||
|
||
[JsonPropertyName("cache_expiration")] | ||
public int CacheExpiration { get; set; } | ||
|
||
public string Status { get; set; } | ||
|
||
public string Addition { get; set; } | ||
|
||
public string Remark { get; set; } | ||
|
||
public DateTime Modified { get; set; } | ||
|
||
public bool Disabled { get; set; } | ||
|
||
[JsonPropertyName("enable_sign")] | ||
public bool EnableSign { get; set; } | ||
|
||
[JsonPropertyName("order_by")] | ||
public string OrderBy { get; set; } | ||
|
||
[JsonPropertyName("order_direction")] | ||
public string OrderDirection { get; set; } | ||
|
||
[JsonPropertyName("extract_folder")] | ||
public string ExtractFolder { get; set; } | ||
|
||
[JsonPropertyName("web_proxy")] | ||
public bool WebProxy { get; set; } | ||
|
||
[JsonPropertyName("webdav_policy")] | ||
public string WebdavPolicy { get; set; } | ||
|
||
[JsonPropertyName("down_proxy_url")] | ||
public string DownProxyUrl { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters