storage: added api descriptions

This commit is contained in:
Natalia Ovchinnikova 2023-03-10 18:52:54 +03:00
parent 51d26ffa9d
commit ff2786ff6c

View File

@ -94,8 +94,16 @@ public class StorageController : BaseSettingsController
_cacheDeleteSchedule = cacheDeleteSchedule; _cacheDeleteSchedule = cacheDeleteSchedule;
_encryptionWorker = encryptionWorker; _encryptionWorker = encryptionWorker;
_securityContext = securityContext; _securityContext = securityContext;
} }
/// <summary>
/// Returns a list of all the portal storages.
/// </summary>
/// <category>Storage</category>
/// <short>Get storages</short>
/// <returns>List of storages</returns>
/// <path>api/2.0/settings/storage</path>
/// <httpMethod>GET</httpMethod>
[HttpGet("storage")] [HttpGet("storage")]
public List<StorageDto> GetAllStorages() public List<StorageDto> GetAllStorages()
{ {
@ -109,8 +117,16 @@ public class StorageController : BaseSettingsController
var current = _settingsManager.Load<StorageSettings>(); var current = _settingsManager.Load<StorageSettings>();
var consumers = _consumerFactory.GetAll<DataStoreConsumer>(); var consumers = _consumerFactory.GetAll<DataStoreConsumer>();
return consumers.Select(consumer => new StorageDto(consumer, current)).ToList(); return consumers.Select(consumer => new StorageDto(consumer, current)).ToList();
} }
/// <summary>
/// Returns the storage progress.
/// </summary>
/// <category>Storage</category>
/// <short>Get the storage progress</short>
/// <returns>Storage progress</returns>
/// <path>api/2.0/settings/storage/progress</path>
/// <httpMethod>GET</httpMethod>
[AllowNotPayment] [AllowNotPayment]
[HttpGet("storage/progress")] [HttpGet("storage/progress")]
public double GetStorageProgress() public double GetStorageProgress()
@ -125,8 +141,17 @@ public class StorageController : BaseSettingsController
return _serviceClient.GetProgress(Tenant.Id); return _serviceClient.GetProgress(Tenant.Id);
} }
public readonly object Locker = new object(); public readonly object Locker = new object();
/// <summary>
/// Starts the storage encryption process.
/// </summary>
/// <short>Start the storage encryption process</short>
/// <category>Encryption</category>
/// <param name="inDto">Specifies if the users will be notified about the encryption process or not</param>
/// <returns>Boolean value: true if the operation is successful</returns>
/// <path>api/2.0/settings/encryption/start</path>
/// <httpMethod>POST</httpMethod>
[HttpPost("encryption/start")] [HttpPost("encryption/start")]
public bool StartStorageEncryption(StorageEncryptionRequestsDto inDto) public bool StartStorageEncryption(StorageEncryptionRequestsDto inDto)
{ {
@ -244,12 +269,16 @@ public class StorageController : BaseSettingsController
tenantId: _tenantManager.GetCurrentTenant().Id tenantId: _tenantManager.GetCurrentTenant().Id
)); ));
} }
/// <summary> /// <summary>
/// Get storage encryption settings /// Returns the storage encryption settings.
/// </summary> /// </summary>
/// <returns>EncryptionSettings</returns> /// <short>Get the storage encryption settings</short>
/// <category>Encryption</category>
/// <returns>Storage encryption settings</returns>
/// <path>api/2.0/settings/encryption/settings</path>
/// <httpMethod>GET</httpMethod>
/// <visible>false</visible> /// <visible>false</visible>
[HttpGet("encryption/settings")] [HttpGet("encryption/settings")]
public EncryptionSettings GetStorageEncryptionSettings() public EncryptionSettings GetStorageEncryptionSettings()
@ -284,8 +313,16 @@ public class StorageController : BaseSettingsController
_log.ErrorGetStorageEncryptionSettings(e); _log.ErrorGetStorageEncryptionSettings(e);
return null; return null;
} }
} }
/// <summary>
/// Returns the storage encryption progress.
/// </summary>
/// <short>Get the storage encryption progress</short>
/// <category>Encryption</category>
/// <returns>Storage encryption progress</returns>
/// <path>api/2.0/settings/encryption/progress</path>
/// <httpMethod>GET</httpMethod>
[HttpGet("encryption/progress")] [HttpGet("encryption/progress")]
public double? GetStorageEncryptionProgress() public double? GetStorageEncryptionProgress()
{ {
@ -305,8 +342,17 @@ public class StorageController : BaseSettingsController
} }
return _encryptionWorker.GetEncryptionProgress(); return _encryptionWorker.GetEncryptionProgress();
} }
/// <summary>
/// Updates a storage with the parameters specified in the request.
/// </summary>
/// <category>Storage</category>
/// <short>Update a storage</short>
/// <param name="inDto">Storage settings: storage name, new storage properties</param>
/// <returns>Updated storage</returns>
/// <path>api/2.0/settings/storage</path>
/// <httpMethod>PUT</httpMethod>
[HttpPut("storage")] [HttpPut("storage")]
public StorageSettings UpdateStorage(StorageRequestsDto inDto) public StorageSettings UpdateStorage(StorageRequestsDto inDto)
{ {
@ -342,8 +388,16 @@ public class StorageController : BaseSettingsController
_log.ErrorUpdateStorage(e); _log.ErrorUpdateStorage(e);
throw; throw;
} }
} }
/// <summary>
/// Resets the storage settings to the default parameters.
/// </summary>
/// <category>Storage</category>
/// <short>Reset the storage settings</short>
/// <path>api/2.0/settings/storage</path>
/// <httpMethod>DELETE</httpMethod>
/// <returns></returns>
[HttpDelete("storage")] [HttpDelete("storage")]
public void ResetStorageToDefault() public void ResetStorageToDefault()
{ {
@ -369,8 +423,16 @@ public class StorageController : BaseSettingsController
_log.ErrorResetStorageToDefault(e); _log.ErrorResetStorageToDefault(e);
throw; throw;
} }
} }
/// <summary>
/// Returns a list of all the CDN storages.
/// </summary>
/// <category>Storage</category>
/// <short>Get the CDN storages</short>
/// <returns>List of the CDN storages</returns>
/// <path>api/2.0/settings/storage/cdn</path>
/// <httpMethod>GET</httpMethod>
[HttpGet("storage/cdn")] [HttpGet("storage/cdn")]
public List<StorageDto> GetAllCdnStorages() public List<StorageDto> GetAllCdnStorages()
{ {
@ -384,8 +446,17 @@ public class StorageController : BaseSettingsController
var current = _settingsManager.Load<CdnStorageSettings>(); var current = _settingsManager.Load<CdnStorageSettings>();
var consumers = _consumerFactory.GetAll<DataStoreConsumer>().Where(r => r.Cdn != null); var consumers = _consumerFactory.GetAll<DataStoreConsumer>().Where(r => r.Cdn != null);
return consumers.Select(consumer => new StorageDto(consumer, current)).ToList(); return consumers.Select(consumer => new StorageDto(consumer, current)).ToList();
} }
/// <summary>
/// Updates the CDN storage with the parameters specified in the request.
/// </summary>
/// <category>Storage</category>
/// <short>Update the CDN storage</short>
/// <returns>Updated CDN storage</returns>
/// <param name="inDto">CDN storage parameters: CDN storage name, new CDN storage properties</param>
/// <path>api/2.0/settings/storage/cdn</path>
/// <httpMethod>PUT</httpMethod>
[HttpPut("storage/cdn")] [HttpPut("storage/cdn")]
public CdnStorageSettings UpdateCdn(StorageRequestsDto inDto) public CdnStorageSettings UpdateCdn(StorageRequestsDto inDto)
{ {
@ -422,8 +493,16 @@ public class StorageController : BaseSettingsController
} }
return settings; return settings;
} }
/// <summary>
/// Resets the CDN storage settings to the default parameters.
/// </summary>
/// <category>Storage</category>
/// <short>Reset the CDN storage settings</short>
/// <path>api/2.0/settings/storage/cdn</path>
/// <httpMethod>DELETE</httpMethod>
/// <returns></returns>
[HttpDelete("storage/cdn")] [HttpDelete("storage/cdn")]
public void ResetCdnToDefault() public void ResetCdnToDefault()
{ {
@ -435,8 +514,16 @@ public class StorageController : BaseSettingsController
} }
_storageSettingsHelper.Clear(_settingsManager.Load<CdnStorageSettings>()); _storageSettingsHelper.Clear(_settingsManager.Load<CdnStorageSettings>());
} }
/// <summary>
/// Returns a list of all the backup storages.
/// </summary>
/// <category>Storage</category>
/// <short>Get the backup storages</short>
/// <returns>List of the backup storages</returns>
/// <path>api/2.0/settings/storage/backup</path>
/// <httpMethod>GET</httpMethod>
[HttpGet("storage/backup")] [HttpGet("storage/backup")]
public List<StorageDto> GetAllBackupStorages() public List<StorageDto> GetAllBackupStorages()
{ {
@ -470,8 +557,10 @@ public class StorageController : BaseSettingsController
/// Returns a list of all Amazon regions. /// Returns a list of all Amazon regions.
/// </summary> /// </summary>
/// <category>Storage</category> /// <category>Storage</category>
/// <short>Get all Amazon regions</short> /// <short>Get Amazon regions</short>
/// <returns>List of the Amazon regions</returns> /// <returns>List of the Amazon regions</returns>
/// <path>api/2.0/settings/storage/s3/regions</path>
/// <httpMethod>GET</httpMethod>
[HttpGet("storage/s3/regions")] [HttpGet("storage/s3/regions")]
public object GetAmazonS3Regions() public object GetAmazonS3Regions()
{ {