diff --git a/doc/dependency_decisions.yml b/doc/dependency_decisions.yml index 369a5c3..76cd665 100644 --- a/doc/dependency_decisions.yml +++ b/doc/dependency_decisions.yml @@ -4,31 +4,28 @@ - :who: mocsharp :why: Apache-2.0 (https://github.com/aws/aws-sdk-net/raw/master/License.txt) :versions: - - 3.7.100.25 - - 3.7.105.20 + - 3.7.200.13 :when: 2022-08-29 18:11:12.923214877 Z - - :approve - AWSSDK.S3 - :who: mocsharp :why: Apache-2.0 (https://github.com/aws/aws-sdk-net/raw/master/License.txt) :versions: - - 3.7.101.25 - - 3.7.103.28 + - 3.7.201.11 :when: 2022-08-29 18:11:13.354973002 Z - - :approve - AWSSDK.SecurityToken - :who: mocsharp :why: Apache-2.0 (https://github.com/aws/aws-sdk-net/raw/master/License.txt) :versions: - - 3.7.100.25 - - 3.7.101.26 + - 3.7.201.9 :when: 2022-08-16 18:11:13.781079769 Z - - :approve - Ardalis.GuardClauses - :who: mocsharp :why: MIT (https://github.com/ardalis/GuardClauses.Analyzers/raw/master/LICENSE) :versions: - - 4.0.1 + - 4.1.1 :when: 2022-08-16 18:11:14.642522140 Z - - :approve - Castle.Core @@ -69,10 +66,9 @@ - - :approve - Microsoft.CodeCoverage - :who: mocsharp - :why: MIT (https://github.com/microsoft/vstest/raw/v17.4.0/LICENSE) + :why: MIT (https://github.com/microsoft/vstest/raw/v17.7.0/LICENSE) :versions: - - 17.4.0 - - 17.5.0 + - 17.7.0 :when: 2022-08-16 18:11:17.245887971 Z - - :approve - Microsoft.Extensions.Configuration @@ -149,14 +145,14 @@ - :who: mocsharp :why: MIT (https://github.com/dotnet/aspnetcore/raw/main/LICENSE.txt) :versions: - - 6.0.15 + - 6.0.21 :when: 2022-08-29 18:11:22.090772006 Z - - :approve - Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions - :who: mocsharp :why: MIT (https://github.com/dotnet/aspnetcore/raw/main/LICENSE.txt) :versions: - - 6.0.15 + - 6.0.21 :when: 2022-08-29 18:11:22.090772006 Z - - :approve - Microsoft.Extensions.FileProviders.Abstractions @@ -205,7 +201,7 @@ - :who: mocsharp :why: MIT (https://github.com/dotnet/runtime/raw/main/LICENSE.TXT) :versions: - - 6.0.3 + - 6.0.4 :when: 2022-08-29 18:11:25.167886026 Z - - :approve - Microsoft.Extensions.Logging.Configuration @@ -266,9 +262,9 @@ - - :approve - Microsoft.NET.Test.Sdk - :who: mocsharp - :why: MIT (https://github.com/microsoft/vstest/raw/v17.4.0/LICENSE) + :why: MIT (https://github.com/microsoft/vstest/raw/v17.7.0/LICENSE) :versions: - - 17.5.0 + - 17.7.0 :when: 2022-08-16 18:11:29.155295778 Z - - :approve - Microsoft.NETCore.Platforms @@ -301,18 +297,16 @@ - - :approve - Microsoft.TestPlatform.ObjectModel - :who: mocsharp - :why: MIT (https://github.com/microsoft/vstest/raw/v17.4.0/LICENSE) + :why: MIT (https://github.com/microsoft/vstest/raw/v17.7.0/LICENSE) :versions: - - 17.4.0 - - 17.5.0 + - 17.7.0 :when: 2022-08-16 18:11:32.293966383 Z - - :approve - Microsoft.TestPlatform.TestHost - :who: mocsharp - :why: MIT (https://github.com/microsoft/vstest/raw/v17.4.0/LICENSE) + :why: MIT (https://github.com/microsoft/vstest/raw/v17.7.0/LICENSE) :versions: - - 17.4.0 - - 17.5.0 + - 17.7.0 :when: 2022-08-16 18:11:33.162650175 Z - - :approve - Microsoft.Win32.Primitives @@ -326,15 +320,14 @@ - :who: mocsharp :why: Apache-2.0 (https://github.com/minio/minio-dotnet/raw/master/LICENSE) :versions: - - 4.0.7 + - 5.0.0 :when: 2022-08-16 18:11:34.443742604 Z - - :approve - Moq - :who: mocsharp :why: BSD 3-Clause License ( https://raw.githubusercontent.com/moq/moq4/main/License.txt) :versions: - - 4.18.2 - - 4.18.4 + - 4.20.1 :when: 2022-08-16 18:11:34.872036382 Z - - :approve - NETStandard.Library @@ -363,7 +356,7 @@ - :who: mocsharp :why: Apache-2.0 (https://github.com/NuGet/NuGet.Client/raw/dev/LICENSE.txt) :versions: - - 5.11.0 + - 6.5.0 :when: 2022-08-16 18:11:36.612121088 Z - - :approve - System.AppContext @@ -480,7 +473,7 @@ - - :approve - System.IO.Abstractions - :who: mocsharp - :why: MIT ( https://github.com/TestableIO/System.IO.Abstractions/raw/main/LICENSE) + :why: MIT ( https://raw.githubusercontent.com/TestableIO/System.IO.Abstractions/main/LICENSE) :versions: - 17.2.3 - 19.2.1 @@ -488,41 +481,11 @@ - - :approve - System.IO.Abstractions.TestingHelpers - :who: mocsharp - :why: MIT ( https://github.com/TestableIO/System.IO.Abstractions/raw/main/LICENSE) - :versions: - - 17.2.3 - - 19.2.1 - :when: 2022-08-16 18:11:44.984891276 Z -- - :approve - - System.IO.Abstractions.Wrappers - - :who: ndsouth - :why: MIT ( https://github.com/TestableIO/System.IO.Abstractions/raw/main/LICENSE) - :versions: - - 19.2.1 - :when: 2023-03-13 17:19:04.984891276 Z -- - :approve - - TestableIO.System.IO.Abstractions - - :who: mocsharp - :why: MIT ( https://github.com/TestableIO/System.IO.Abstractions/raw/main/LICENSE) - :versions: - - 17.2.3 - - 19.2.1 - :when: 2022-08-16 18:11:44.550586685 Z -- - :approve - - TestableIO.System.IO.Abstractions.TestingHelpers - - :who: mocsharp - :why: MIT ( https://github.com/TestableIO/System.IO.Abstractions/raw/main/LICENSE) + :why: MIT ( https://raw.githubusercontent.com/TestableIO/System.IO.Abstractions/main/LICENSE) :versions: - 17.2.3 - 19.2.1 :when: 2022-08-16 18:11:44.984891276 Z -- - :approve - - TestableIO.System.IO.Abstractions.Wrappers - - :who: ndsouth - :why: MIT ( https://github.com/TestableIO/System.IO.Abstractions/raw/main/LICENSE) - :versions: - - 19.2.1 - :when: 2023-03-13 17:19:04.984891276 Z - - :approve - System.IO.Compression - :who: mocsharp @@ -927,7 +890,7 @@ - :who: mocsharp :why: MIT (https://github.com/coverlet-coverage/coverlet/raw/master/LICENSE) :versions: - - 3.2.0 + - 6.0.0 :when: 2022-08-16 18:12:11.244463651 Z - - :approve - runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl @@ -1123,7 +1086,7 @@ - :who: mocsharp :why: Apache-2.0 ( https://raw.githubusercontent.com/xunit/xunit/master/license.txt) :versions: - - 2.4.2 + - 2.5.0 :when: 2022-08-16 18:12:23.908089715 Z - - :approve - xunit.abstractions @@ -1137,35 +1100,35 @@ - :who: mocsharp :why: Apache-2.0 ( https://raw.githubusercontent.com/xunit/xunit.analyzers/master/LICENSE) :versions: - - 1.0.0 + - 1.2.0 :when: 2022-08-16 18:12:24.794067387 Z - - :approve - xunit.assert - :who: mocsharp :why: Apache-2.0 ( https://raw.githubusercontent.com/xunit/xunit/master/license.txt) :versions: - - 2.4.2 + - 2.5.0 :when: 2022-08-16 18:12:25.267072818 Z - - :approve - xunit.core - :who: mocsharp :why: Apache-2.0 ( https://raw.githubusercontent.com/xunit/xunit/master/license.txt) :versions: - - 2.4.2 + - 2.5.0 :when: 2022-08-16 18:12:25.712645737 Z - - :approve - xunit.extensibility.core - :who: mocsharp :why: Apache-2.0 ( https://raw.githubusercontent.com/xunit/xunit/master/license.txt) :versions: - - 2.4.2 + - 2.5.0 :when: 2022-08-16 18:12:26.153575547 Z - - :approve - xunit.extensibility.execution - :who: mocsharp :why: Apache-2.0 ( https://raw.githubusercontent.com/xunit/xunit/master/license.txt) :versions: - - 2.4.2 + - 2.5.0 :when: 2022-08-16 18:12:26.592263714 Z - - :approve - xunit.runner.visualstudio @@ -1179,7 +1142,7 @@ - :who: mocsharp :why: MIT ( https://licenses.nuget.org/MIT) :versions: - - 2.4.5 + - 2.5.0 :when: 2022-08-16 18:12:27.491158618 Z - - :approve - Dangl.Xunit.Extensions.Ordering @@ -1193,8 +1156,7 @@ - :who: mocsharp :why: Apache-2.0 (https://github.com/fluentassertions/fluentassertions/raw/develop/LICENSE) :versions: - - 6.8.0 - - 6.10.0 + - 6.11.0 :when: 2022-11-28 18:12:27.491158618 Z - - :approve - System.Configuration.ConfigurationManager @@ -1210,6 +1172,34 @@ :versions: - 4.4.0 :when: 2022-08-16 23:07:14.759818552 Z +- - :approve + - CommunityToolkit.HighPerformance + - :who: mocsharp + :why: MIT (https://raw.githubusercontent.com/CommunityToolkit/dotnet/main/License.md) + :versions: + - 8.1.0 + :when: 2023-08-10 20:50:14.759818552 Z +- - :approve + - Devlooped.SponsorLink + - :who: mocsharp + :why: MIT (https://licenses.nuget.org/MIT) + :versions: + - 1.0.0 + :when: 2023-08-10 20:50:14.759818552 Z +- - :approve + - System.IO.Hashing + - :who: mocsharp + :why: MIT (https://raw.githubusercontent.com/dotnet/runtime/main/LICENSE.TXT) + :versions: + - 7.0.0 + :when: 2023-08-10 20:50:14.759818552 Z + + + + + + + diff --git a/src/Plugins/AWSS3/AWS3StorageService.cs b/src/Plugins/AWSS3/AWS3StorageService.cs index ca2cc55..8ffeab8 100644 --- a/src/Plugins/AWSS3/AWS3StorageService.cs +++ b/src/Plugins/AWSS3/AWS3StorageService.cs @@ -47,7 +47,7 @@ public class Awss3StorageService : IStorageService public Awss3StorageService(IOptions options, ILogger logger) { - Guard.Against.Null(options); + Guard.Against.Null(options, nameof(options)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); @@ -73,7 +73,7 @@ public Awss3StorageService(IOptions options, ILogge private void ValidateConfiguration(StorageServiceConfiguration configuration) { - Guard.Against.Null(configuration); + Guard.Against.Null(configuration, nameof(configuration)); foreach (var key in ConfigurationKeys.RequiredKeys) { @@ -88,18 +88,18 @@ private void ValidateConfiguration(StorageServiceConfiguration configuration) public async Task CopyObjectAsync(string sourceBucketName, string sourceObjectName, string destinationBucketName, string destinationObjectName, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(sourceBucketName); - Guard.Against.NullOrWhiteSpace(sourceObjectName); - Guard.Against.NullOrWhiteSpace(destinationBucketName); - Guard.Against.NullOrWhiteSpace(destinationObjectName); + Guard.Against.NullOrWhiteSpace(sourceBucketName, nameof(sourceBucketName)); + Guard.Against.NullOrWhiteSpace(sourceObjectName, nameof(sourceObjectName)); + Guard.Against.NullOrWhiteSpace(destinationBucketName, nameof(destinationBucketName)); + Guard.Against.NullOrWhiteSpace(destinationObjectName, nameof(destinationObjectName)); await _client.CopyObjectAsync(sourceBucketName, sourceObjectName, destinationBucketName, destinationObjectName, cancellationToken: cancellationToken).ConfigureAwait(false); } public async Task GetObjectAsync(string bucketName, string objectName, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); var obj = await _client.GetObjectAsync(bucketName, objectName, cancellationToken: cancellationToken).ConfigureAwait(false); @@ -108,7 +108,7 @@ public async Task GetObjectAsync(string bucketName, string objectName, C public async Task> ListObjectsAsync(string bucketName, string prefix = "", bool recursive = false, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); var request = new ListObjectsV2Request { BucketName = bucketName, Prefix = prefix }; var files = new List(); @@ -129,10 +129,10 @@ public async Task> ListObjectsAsync(string bucketName, st public async Task PutObjectAsync(string bucketName, string objectName, Stream data, long size, string contentType, Dictionary metadata, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); - Guard.Against.Null(data); - Guard.Against.NullOrWhiteSpace(contentType); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); + Guard.Against.Null(data, nameof(data)); + Guard.Against.NullOrWhiteSpace(contentType, nameof(contentType)); var por = new PutObjectRequest { @@ -144,8 +144,8 @@ public async Task PutObjectAsync(string bucketName, string objectName, Stream da public async Task RemoveObjectAsync(string bucketName, string objectName, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); var dor = new DeleteObjectRequest { BucketName = bucketName, Key = objectName }; @@ -154,8 +154,8 @@ public async Task RemoveObjectAsync(string bucketName, string objectName, Cancel public async Task RemoveObjectsAsync(string bucketName, IEnumerable objectNames, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrEmpty(objectNames); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrEmpty(objectNames, nameof(objectNames)); var KeyVersionList = new List(); foreach (var objectName in objectNames) @@ -174,8 +174,8 @@ public async Task RemoveObjectsAsync(string bucketName, IEnumerable obje public async Task CreateFolderAsync(string bucketName, string folderPath, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrEmpty(folderPath); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrEmpty(folderPath, nameof(folderPath)); var stubFile = folderPath + "/stubFile.txt"; @@ -186,8 +186,8 @@ public async Task CreateFolderAsync(string bucketName, string folderPath, Cancel public async Task CreateTemporaryCredentialsAsync(string bucketName, string folderName, int durationSeconds = 3600, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrEmpty(folderName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrEmpty(folderName, nameof(folderName)); var policy = PolicyExtensions.ToPolicy(bucketName, folderName); @@ -210,10 +210,10 @@ public async Task CreateTemporaryCredentialsAsync(string bucketName public async Task CopyObjectWithCredentialsAsync(string sourceBucketName, string sourceObjectName, string destinationBucketName, string destinationObjectName, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(sourceBucketName); - Guard.Against.NullOrWhiteSpace(sourceObjectName); - Guard.Against.NullOrWhiteSpace(destinationBucketName); - Guard.Against.NullOrWhiteSpace(destinationObjectName); + Guard.Against.NullOrWhiteSpace(sourceBucketName, nameof(sourceBucketName)); + Guard.Against.NullOrWhiteSpace(sourceObjectName, nameof(sourceObjectName)); + Guard.Against.NullOrWhiteSpace(destinationBucketName, nameof(destinationBucketName)); + Guard.Against.NullOrWhiteSpace(destinationObjectName, nameof(destinationObjectName)); IsCredentialsNull(credentials); var client = new AmazonS3Client(credentials.AccessKeyId, credentials.SecretAccessKey, RegionEndpoint.GetBySystemName(_options.Settings[ConfigurationKeys.Region])); @@ -222,8 +222,8 @@ public async Task CopyObjectWithCredentialsAsync(string sourceBucketName, string public async Task GetObjectWithCredentialsAsync(string bucketName, string objectName, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); IsCredentialsNull(credentials); var client = new AmazonS3Client(credentials.AccessKeyId, credentials.SecretAccessKey, RegionEndpoint.GetBySystemName(_options.Settings[ConfigurationKeys.Region])); @@ -235,7 +235,7 @@ public async Task GetObjectWithCredentialsAsync(string bucketName, strin public async Task> ListObjectsWithCredentialsAsync(string bucketName, Credentials credentials, string prefix = "", bool recursive = false, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); IsCredentialsNull(credentials); var client = new AmazonS3Client(credentials.AccessKeyId, credentials.SecretAccessKey, RegionEndpoint.GetBySystemName(_options.Settings[ConfigurationKeys.Region])); @@ -259,10 +259,10 @@ public async Task> ListObjectsWithCredentialsAsync(string public async Task PutObjectWithCredentialsAsync(string bucketName, string objectName, Stream data, long size, string contentType, Dictionary metadata, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); - Guard.Against.Null(data); - Guard.Against.NullOrWhiteSpace(contentType); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); + Guard.Against.Null(data, nameof(data)); + Guard.Against.NullOrWhiteSpace(contentType, nameof(contentType)); IsCredentialsNull(credentials); var client = new AmazonS3Client(credentials.AccessKeyId, credentials.SecretAccessKey, RegionEndpoint.GetBySystemName(_options.Settings[ConfigurationKeys.Region])); @@ -276,8 +276,8 @@ public async Task PutObjectWithCredentialsAsync(string bucketName, string object public async Task RemoveObjectWithCredentialsAsync(string bucketName, string objectName, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); IsCredentialsNull(credentials); var client = new AmazonS3Client(credentials.AccessKeyId, credentials.SecretAccessKey, RegionEndpoint.GetBySystemName(_options.Settings[ConfigurationKeys.Region])); @@ -289,8 +289,8 @@ public async Task RemoveObjectWithCredentialsAsync(string bucketName, string obj public async Task RemoveObjectsWithCredentialsAsync(string bucketName, IEnumerable objectNames, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrEmpty(objectNames); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrEmpty(objectNames, nameof(objectNames)); var client = new AmazonS3Client(credentials.AccessKeyId, credentials.SecretAccessKey, RegionEndpoint.GetBySystemName(_options.Settings[ConfigurationKeys.Region])); @@ -311,8 +311,8 @@ public async Task RemoveObjectsWithCredentialsAsync(string bucketName, IEnumerab public async Task CreateFolderWithCredentialsAsync(string bucketName, string folderPath, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrEmpty(folderPath); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrEmpty(folderPath, nameof(folderPath)); IsCredentialsNull(credentials); var client = new AmazonS3Client(credentials.AccessKeyId, credentials.SecretAccessKey, RegionEndpoint.GetBySystemName(_options.Settings[ConfigurationKeys.Region])); @@ -328,16 +328,16 @@ public async Task CreateFolderWithCredentialsAsync(string bucketName, string fol private void IsCredentialsNull(Credentials credentials) { - Guard.Against.Null(credentials); - Guard.Against.NullOrWhiteSpace(credentials.AccessKeyId); - Guard.Against.NullOrWhiteSpace(credentials.SecretAccessKey); - Guard.Against.NullOrWhiteSpace(credentials.SessionToken); + Guard.Against.Null(credentials, nameof(credentials)); + Guard.Against.NullOrWhiteSpace(credentials.AccessKeyId, nameof(credentials.AccessKeyId)); + Guard.Against.NullOrWhiteSpace(credentials.SecretAccessKey, nameof(credentials.SecretAccessKey)); + Guard.Against.NullOrWhiteSpace(credentials.SessionToken, nameof(credentials.SessionToken)); } public async Task> VerifyObjectsExistAsync(string bucketName, IReadOnlyList artifactList, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.Null(artifactList); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.Null(artifactList, nameof(artifactList)); var existingObjectsDict = new Dictionary(); @@ -370,8 +370,8 @@ public async Task> VerifyObjectsExistAsync(string bucke public async Task VerifyObjectExistsAsync(string bucketName, string artifactName, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(artifactName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(artifactName, nameof(artifactName)); var fileObjects = await ListObjectsAsync(bucketName, artifactName); var folderObjects = await ListObjectsAsync(bucketName, artifactName.EndsWith("/") ? artifactName : $"{artifactName}/", true); diff --git a/src/Plugins/AWSS3/Monai.Deploy.Storage.AWSS3.csproj b/src/Plugins/AWSS3/Monai.Deploy.Storage.AWSS3.csproj index 46f5a8a..b9ca619 100644 --- a/src/Plugins/AWSS3/Monai.Deploy.Storage.AWSS3.csproj +++ b/src/Plugins/AWSS3/Monai.Deploy.Storage.AWSS3.csproj @@ -48,9 +48,9 @@ - - - + + + diff --git a/src/Plugins/MinIO/MinIoStartup.cs b/src/Plugins/MinIO/MinIoStartup.cs index 77befbe..0d66b6d 100644 --- a/src/Plugins/MinIO/MinIoStartup.cs +++ b/src/Plugins/MinIO/MinIoStartup.cs @@ -85,8 +85,8 @@ public Task StopAsync(CancellationToken cancellationToken) private async Task CreateBucket(IBucketOperations client, string bucket, string region, CancellationToken cancellationToken) { - Guard.Against.Null(client); - Guard.Against.Null(bucket); + Guard.Against.Null(client, nameof(client)); + Guard.Against.Null(bucket, nameof(bucket)); var bucketExistsArgs = new BucketExistsArgs().WithBucket(bucket); if (!await client.BucketExistsAsync(bucketExistsArgs, cancellationToken).ConfigureAwait(false)) diff --git a/src/Plugins/MinIO/MinIoStorageService.cs b/src/Plugins/MinIO/MinIoStorageService.cs index d44a15f..d00386f 100644 --- a/src/Plugins/MinIO/MinIoStorageService.cs +++ b/src/Plugins/MinIO/MinIoStorageService.cs @@ -40,7 +40,7 @@ public class MinIoStorageService : IStorageService public MinIoStorageService(IMinIoClientFactory minioClientFactory, IAmazonSecurityTokenServiceClientFactory amazonSecurityTokenServiceClientFactory, IOptions options, ILogger logger) { - Guard.Against.Null(options); + Guard.Against.Null(options, nameof(options)); _minioClientFactory = minioClientFactory ?? throw new ArgumentNullException(nameof(minioClientFactory)); _amazonSecurityTokenServiceClientFactory = amazonSecurityTokenServiceClientFactory ?? throw new ArgumentNullException(nameof(amazonSecurityTokenServiceClientFactory)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); @@ -53,7 +53,7 @@ public MinIoStorageService(IMinIoClientFactory minioClientFactory, IAmazonSecuri private void ValidateConfiguration(StorageServiceConfiguration configuration) { - Guard.Against.Null(configuration); + Guard.Against.Null(configuration, nameof(configuration)); foreach (var key in ConfigurationKeys.RequiredKeys) { @@ -68,10 +68,10 @@ private void ValidateConfiguration(StorageServiceConfiguration configuration) public async Task CopyObjectAsync(string sourceBucketName, string sourceObjectName, string destinationBucketName, string destinationObjectName, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(sourceBucketName); - Guard.Against.NullOrWhiteSpace(sourceObjectName); - Guard.Against.NullOrWhiteSpace(destinationBucketName); - Guard.Against.NullOrWhiteSpace(destinationObjectName); + Guard.Against.NullOrWhiteSpace(sourceBucketName, nameof(sourceBucketName)); + Guard.Against.NullOrWhiteSpace(sourceObjectName, nameof(sourceObjectName)); + Guard.Against.NullOrWhiteSpace(destinationBucketName, nameof(destinationBucketName)); + Guard.Against.NullOrWhiteSpace(destinationObjectName, nameof(destinationObjectName)); var client = _minioClientFactory.GetObjectOperationsClient(); await CopyObjectUsingClient(client, sourceBucketName, sourceObjectName, destinationBucketName, destinationObjectName, cancellationToken).ConfigureAwait(false); @@ -79,8 +79,8 @@ public async Task CopyObjectAsync(string sourceBucketName, string sourceObjectNa public async Task GetObjectAsync(string bucketName, string objectName, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); var client = _minioClientFactory.GetObjectOperationsClient(); var stream = new MemoryStream(); @@ -91,7 +91,7 @@ public async Task GetObjectAsync(string bucketName, string objectName, C public async Task> ListObjectsAsync(string bucketName, string? prefix = "", bool recursive = false, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); var client = _minioClientFactory.GetBucketOperationsClient(); return await ListObjectsUsingClient(client, bucketName, prefix, recursive, cancellationToken).ConfigureAwait(false); @@ -99,8 +99,8 @@ public async Task> ListObjectsAsync(string bucketName, st public async Task> VerifyObjectsExistAsync(string bucketName, IReadOnlyList artifactList, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.Null(artifactList); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.Null(artifactList, nameof(artifactList)); var existingObjectsDict = new Dictionary(); var exceptions = new List(); @@ -138,8 +138,8 @@ public async Task> VerifyObjectsExistAsync(string bucke public async Task VerifyObjectExistsAsync(string bucketName, string artifactName, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(artifactName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(artifactName, nameof(artifactName)); try { @@ -164,10 +164,10 @@ public async Task VerifyObjectExistsAsync(string bucketName, string artifa public async Task PutObjectAsync(string bucketName, string objectName, Stream data, long size, string contentType, Dictionary? metadata, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); - Guard.Against.Null(data); - Guard.Against.NullOrWhiteSpace(contentType); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); + Guard.Against.Null(data, nameof(data)); + Guard.Against.NullOrWhiteSpace(contentType, nameof(contentType)); var client = _minioClientFactory.GetObjectOperationsClient(); await PutObjectUsingClient(client, bucketName, objectName, data, size, contentType, metadata, cancellationToken).ConfigureAwait(false); @@ -175,8 +175,8 @@ public async Task PutObjectAsync(string bucketName, string objectName, Stream da public async Task RemoveObjectAsync(string bucketName, string objectName, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); var client = _minioClientFactory.GetObjectOperationsClient(); await RemoveObjectUsingClient(client, bucketName, objectName, cancellationToken).ConfigureAwait(false); @@ -184,8 +184,8 @@ public async Task RemoveObjectAsync(string bucketName, string objectName, Cancel public async Task RemoveObjectsAsync(string bucketName, IEnumerable objectNames, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrEmpty(objectNames); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrEmpty(objectNames, nameof(objectNames)); var client = _minioClientFactory.GetObjectOperationsClient(); await RemoveObjectsUsingClient(client, bucketName, objectNames, cancellationToken).ConfigureAwait(false); @@ -193,8 +193,8 @@ public async Task RemoveObjectsAsync(string bucketName, IEnumerable obje public async Task CreateFolderAsync(string bucketName, string folderPath, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrEmpty(folderPath); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrEmpty(folderPath, nameof(folderPath)); var stubFile = folderPath + "/stubFile.txt"; @@ -211,8 +211,8 @@ public async Task CreateFolderAsync(string bucketName, string folderPath, Cancel public async Task CreateTemporaryCredentialsAsync(string bucketName, string folderName, int durationSeconds = 3600, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrEmpty(folderName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrEmpty(folderName, nameof(folderName)); var policy = PolicyExtensions.ToPolicy(bucketName, folderName); @@ -233,10 +233,10 @@ public async Task CreateTemporaryCredentialsAsync(string bucketName public async Task CopyObjectWithCredentialsAsync(string sourceBucketName, string sourceObjectName, string destinationBucketName, string destinationObjectName, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(sourceBucketName); - Guard.Against.NullOrWhiteSpace(sourceObjectName); - Guard.Against.NullOrWhiteSpace(destinationBucketName); - Guard.Against.NullOrWhiteSpace(destinationObjectName); + Guard.Against.NullOrWhiteSpace(sourceBucketName, nameof(sourceBucketName)); + Guard.Against.NullOrWhiteSpace(sourceObjectName, nameof(sourceObjectName)); + Guard.Against.NullOrWhiteSpace(destinationBucketName, nameof(destinationBucketName)); + Guard.Against.NullOrWhiteSpace(destinationObjectName, nameof(destinationObjectName)); var client = _minioClientFactory.GetObjectOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); await CopyObjectUsingClient(client, sourceBucketName, sourceObjectName, destinationBucketName, destinationObjectName, cancellationToken).ConfigureAwait(false); @@ -244,8 +244,8 @@ public async Task CopyObjectWithCredentialsAsync(string sourceBucketName, string public async Task GetObjectWithCredentialsAsync(string bucketName, string objectName, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); var client = _minioClientFactory.GetObjectOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); var stream = new MemoryStream(); @@ -256,7 +256,7 @@ public async Task GetObjectWithCredentialsAsync(string bucketName, strin public async Task> ListObjectsWithCredentialsAsync(string bucketName, Credentials credentials, string? prefix = "", bool recursive = false, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); var client = _minioClientFactory.GetBucketOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); return await ListObjectsUsingClient(client, bucketName, prefix, recursive, cancellationToken).ConfigureAwait(false); @@ -264,10 +264,10 @@ public async Task> ListObjectsWithCredentialsAsync(string public async Task PutObjectWithCredentialsAsync(string bucketName, string objectName, Stream data, long size, string contentType, Dictionary metadata, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); - Guard.Against.Null(data); - Guard.Against.NullOrWhiteSpace(contentType); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); + Guard.Against.Null(data, nameof(data)); + Guard.Against.NullOrWhiteSpace(contentType, nameof(contentType)); var client = _minioClientFactory.GetObjectOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); await PutObjectUsingClient(client, bucketName, objectName, data, size, contentType, metadata, cancellationToken).ConfigureAwait(false); @@ -275,8 +275,8 @@ public async Task PutObjectWithCredentialsAsync(string bucketName, string object public async Task RemoveObjectWithCredentialsAsync(string bucketName, string objectName, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrWhiteSpace(objectName); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrWhiteSpace(objectName, nameof(objectName)); var client = _minioClientFactory.GetObjectOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); await RemoveObjectUsingClient(client, bucketName, objectName, cancellationToken: cancellationToken).ConfigureAwait(false); @@ -284,8 +284,8 @@ public async Task RemoveObjectWithCredentialsAsync(string bucketName, string obj public async Task RemoveObjectsWithCredentialsAsync(string bucketName, IEnumerable objectNames, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrEmpty(objectNames); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrEmpty(objectNames, nameof(objectNames)); var client = _minioClientFactory.GetObjectOperationsClient(credentials, _options.Settings[ConfigurationKeys.Region]); await RemoveObjectsUsingClient(client, bucketName, objectNames, cancellationToken: cancellationToken).ConfigureAwait(false); @@ -293,8 +293,8 @@ public async Task RemoveObjectsWithCredentialsAsync(string bucketName, IEnumerab public async Task CreateFolderWithCredentialsAsync(string bucketName, string folderPath, Credentials credentials, CancellationToken cancellationToken = default) { - Guard.Against.NullOrWhiteSpace(bucketName); - Guard.Against.NullOrEmpty(folderPath); + Guard.Against.NullOrWhiteSpace(bucketName, nameof(bucketName)); + Guard.Against.NullOrEmpty(folderPath, nameof(folderPath)); var stubFile = folderPath + "/stubFile.txt"; diff --git a/src/Plugins/MinIO/Monai.Deploy.Storage.MinIO.csproj b/src/Plugins/MinIO/Monai.Deploy.Storage.MinIO.csproj index b0eda39..af29cec 100644 --- a/src/Plugins/MinIO/Monai.Deploy.Storage.MinIO.csproj +++ b/src/Plugins/MinIO/Monai.Deploy.Storage.MinIO.csproj @@ -1,4 +1,4 @@ -