public async Task <InvokeResult> UpdateDataStreamAsync(DataStream stream, EntityHeader org, EntityHeader user) { await AuthorizeAsync(stream, AuthorizeResult.AuthorizeActions.Update, user, org); ValidationCheck(stream, Actions.Update); if (!String.IsNullOrEmpty(stream.ConnectionString)) { var addSecretResult = await _secureStorage.AddSecretAsync(stream.ConnectionString); if (!addSecretResult.Successful) { return(addSecretResult.ToInvokeResult()); } if (!string.IsNullOrEmpty(stream.SecureConnectionStringId)) { await _secureStorage.RemoveSecretAsync(stream.SecureConnectionStringId); } stream.SecureConnectionStringId = addSecretResult.Result; stream.ConnectionString = null; } await _dataStreamRepo.UpdateDataStreamAsync(stream); return(InvokeResult.Success); }
public async Task <InvokeResult> UpdateDataStreamAsync(DataStream stream, EntityHeader org, EntityHeader user) { await AuthorizeAsync(stream, AuthorizeResult.AuthorizeActions.Update, user, org); ValidationCheck(stream, Actions.Update); if (stream.StreamType.Value == DataStreamTypes.AzureBlob || stream.StreamType.Value == DataStreamTypes.AzureEventHub || stream.StreamType.Value == DataStreamTypes.AzureTableStorage || stream.StreamType.Value == DataStreamTypes.AzureTableStorage_Managed) { if (!String.IsNullOrEmpty(stream.AzureAccessKey)) { var addSecretResult = await _secureStorage.AddSecretAsync(org, stream.AzureAccessKey); if (!addSecretResult.Successful) { return(addSecretResult.ToInvokeResult()); } if (!string.IsNullOrEmpty(stream.AzureAccessKeySecureId)) { await _secureStorage.RemoveSecretAsync(org, stream.AzureAccessKeySecureId); } stream.AzureAccessKeySecureId = addSecretResult.Result; stream.AzureAccessKey = null; } } else if (stream.StreamType.Value == DataStreamTypes.AWSS3 || stream.StreamType.Value == DataStreamTypes.AWSElasticSearch) { if (!String.IsNullOrEmpty(stream.AwsSecretKey)) { var addSecretResult = await _secureStorage.AddSecretAsync(org, stream.AwsSecretKey); if (!addSecretResult.Successful) { return(addSecretResult.ToInvokeResult()); } if (!string.IsNullOrEmpty(stream.AWSSecretKeySecureId)) { await _secureStorage.RemoveSecretAsync(org, stream.AWSSecretKeySecureId); } stream.AWSSecretKeySecureId = addSecretResult.Result; stream.AwsSecretKey = null; } } else if (stream.StreamType.Value == DataStreamTypes.SQLServer || stream.StreamType.Value == DataStreamTypes.Postgresql) { if (!String.IsNullOrEmpty(stream.DbPassword)) { var addSecretResult = await _secureStorage.AddSecretAsync(org, stream.DbPassword); if (!addSecretResult.Successful) { return(addSecretResult.ToInvokeResult()); } if (!string.IsNullOrEmpty(stream.DBPasswordSecureId)) { await _secureStorage.RemoveSecretAsync(org, stream.DBPasswordSecureId); } stream.DBPasswordSecureId = addSecretResult.Result; stream.DbPassword = null; } } else if (stream.StreamType.Value == DataStreamTypes.Redis) { if (!String.IsNullOrEmpty(stream.RedisPassword)) { var addSecretResult = await _secureStorage.AddSecretAsync(org, stream.RedisPassword); if (!addSecretResult.Successful) { return(addSecretResult.ToInvokeResult()); } if (!string.IsNullOrEmpty(stream.RedisPasswordSecureId)) { await _secureStorage.RemoveSecretAsync(org, stream.RedisPasswordSecureId); } stream.RedisPasswordSecureId = addSecretResult.Result; stream.RedisPassword = null; } } await _dataStreamRepo.UpdateDataStreamAsync(stream); return(InvokeResult.Success); }