Skip to content

Commit 41b0f74

Browse files
author
FrendsFspAiBot
committed
FSPW-385 Adding migration and updating CHANGELOG.mg
1 parent 8a7a57a commit 41b0f74

File tree

7 files changed

+178
-47
lines changed

7 files changed

+178
-47
lines changed

Frends.AmazonS3.DownloadObject/CHANGELOG.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,57 @@
1-
# Changelog
1+
# Changelog
2+
3+
## [3.0.0] - 2025-07-17
4+
5+
## [Breaking] Major refactoring - restructured parameters into Input, Connection, and Options classes with improved error handling
6+
7+
### Breaking Changes
8+
- **Parameter Structure Reorganization**: Task parameters have been restructured into three main classes:
9+
- **Input**: Contains core task parameters (BucketName, SourceDirectory, SearchPattern, DownloadFromCurrentDirectoryOnly, TargetDirectory)
10+
- **Connection**: Contains connection-related parameters (AwsCredentials, PreSignedUrl)
11+
- **Options**: Contains optional configuration parameters (FileLockedRetries, DeleteSourceObject, ThrowErrorIfNoMatch, ActionOnExistingFile, ThrowErrorOnFailure, ErrorMessageOnFailure)
12+
13+
### Parameter Changes
14+
- **Moved to Input tab**:
15+
- `Connection.BucketName``Input.BucketName`
16+
- `Connection.S3Directory``Input.SourceDirectory` (renamed)
17+
- `Connection.SearchPattern``Input.SearchPattern`
18+
- `Connection.DownloadFromCurrentDirectoryOnly``Input.DownloadFromCurrentDirectoryOnly`
19+
- `Connection.DestinationDirectory``Input.TargetDirectory` (renamed)
20+
21+
- **Moved to Options tab**:
22+
- `Connection.FileLockedRetries``Options.FileLockedRetries`
23+
- `Connection.DeleteSourceObject``Options.DeleteSourceObject`
24+
- `Connection.ThrowErrorIfNoMatch``Options.ThrowErrorIfNoMatch`
25+
- `Connection.DestinationFileExistsAction``Options.ActionOnExistingFile` (renamed)
26+
27+
- **Updated in Connection tab**:
28+
- `Connection.AWSCredentials``Connection.AwsCredentials` (renamed)
29+
- `Connection.PreSignedURL``Connection.PreSignedUrl` (renamed)
30+
31+
### New Features
32+
- **Enhanced Error Handling**: Added comprehensive error handling with new Options properties:
33+
- `ThrowErrorOnFailure` (bool, default: false) - Controls whether errors throw exceptions
34+
- `ErrorMessageOnFailure` (string, default: "") - Custom error message for failures
35+
- **Improved Result Structure**:
36+
- Renamed `Data` property to `Objects` in Result class
37+
- Added structured `Error` property with `Message` and `AdditionalInfo` fields
38+
- **Error Handler Helper**: New static ErrorHandler class for consistent error processing
39+
40+
### Migration Guide
41+
To upgrade to the new version:
42+
1. **Input tab**: Select the same values for BucketName, SourceDirectory (previously S3Directory), SearchPattern, DownloadFromCurrentDirectoryOnly, and TargetDirectory (previously DestinationDirectory) as they were in the Connection tab
43+
2. **Options tab**: Configure FileLockedRetries, DeleteSourceObject, ThrowErrorIfNoMatch, and ActionOnExistingFile (previously DestinationFileExistsAction) with the same values as they were in the Connection tab
44+
3. **Connection tab**: Update references to AwsCredentials (previously AWSCredentials) and PreSignedUrl (previously PreSignedURL)
45+
4. **Result handling**: Update code that references `result.Data` to use `result.Objects` instead
46+
5. **Error handling**: Consider setting `ThrowErrorOnFailure` to true and providing custom `ErrorMessageOnFailure` if needed
47+
48+
### Technical Improvements
49+
- Separated concerns by organizing parameters into logical groups (Input, Connection, Options)
50+
- Implemented consistent error handling pattern following Frends task guidelines
51+
- Added proper error reporting with structured Error objects
52+
- Improved naming consistency (AWS → Aws, URL → Url)
53+
- Enhanced maintainability and testability with better class structure
54+
255

356
## [2.2.0] - 2024-12-11
457
### Updated

Frends.AmazonS3.DownloadObject/Frends.AmazonS3.DownloadObject.Tests/UnitTests.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public async Task PreSignedURL_Info_Exists_Test()
144144
AwsSecretAccessKey = _connection.AwsSecretAccessKey,
145145
Region = _connection.Region
146146
};
147-
147+
148148
var options = new Options
149149
{
150150
ActionOnExistingFile = DestinationFileExistsActions.Info,
@@ -179,7 +179,7 @@ public async Task PreSignedURL_Error_Exists_Test()
179179
AwsSecretAccessKey = _connection.AwsSecretAccessKey,
180180
Region = _connection.Region
181181
};
182-
182+
183183
var options = new Options
184184
{
185185
ActionOnExistingFile = DestinationFileExistsActions.Error,
@@ -228,7 +228,7 @@ public async Task PreSignedURL_MissingDestinationDirectory_Test()
228228
AwsSecretAccessKey = _connection.AwsSecretAccessKey,
229229
Region = _connection.Region
230230
};
231-
231+
232232
var input = new Input
233233
{
234234
BucketName = _input.BucketName,
@@ -261,7 +261,7 @@ public async Task AWSCreds_DownloadFiles_TestAllDestinationFileExistsActions_Tes
261261
Region = _connection.Region,
262262
PreSignedUrl = _connection.PreSignedUrl
263263
};
264-
264+
265265
var options = new Options
266266
{
267267
ActionOnExistingFile = action,
@@ -271,7 +271,7 @@ public async Task AWSCreds_DownloadFiles_TestAllDestinationFileExistsActions_Tes
271271
ThrowErrorOnFailure = _options.ThrowErrorOnFailure,
272272
ErrorMessageOnFailure = _options.ErrorMessageOnFailure
273273
};
274-
274+
275275
var input = new Input
276276
{
277277
BucketName = _input.BucketName,
@@ -301,7 +301,7 @@ public async Task AWSCreds_DownloadFiles_Info_Exists_Test()
301301
Region = _connection.Region,
302302
PreSignedUrl = _connection.PreSignedUrl
303303
};
304-
304+
305305
var options = new Options
306306
{
307307
ActionOnExistingFile = DestinationFileExistsActions.Info,
@@ -311,7 +311,7 @@ public async Task AWSCreds_DownloadFiles_Info_Exists_Test()
311311
ThrowErrorOnFailure = _options.ThrowErrorOnFailure,
312312
ErrorMessageOnFailure = _options.ErrorMessageOnFailure
313313
};
314-
314+
315315
var input = new Input
316316
{
317317
BucketName = _input.BucketName,
@@ -343,7 +343,7 @@ public async Task AWSCreds_DownloadFiles_Error_Exists_Test()
343343
Region = _connection.Region,
344344
PreSignedUrl = _connection.PreSignedUrl
345345
};
346-
346+
347347
var options = new Options
348348
{
349349
ActionOnExistingFile = DestinationFileExistsActions.Error,
@@ -374,7 +374,7 @@ public async Task AWSCreds_DeleteSource_Test()
374374
Region = _connection.Region,
375375
PreSignedUrl = _connection.PreSignedUrl
376376
};
377-
377+
378378
var options = new Options
379379
{
380380
DeleteSourceObject = true,
@@ -407,7 +407,7 @@ public async Task AWSCreds_Pattern_Test()
407407
Region = _connection.Region,
408408
PreSignedUrl = _connection.PreSignedUrl
409409
};
410-
410+
411411
var input = new Input
412412
{
413413
BucketName = _input.BucketName,
@@ -439,7 +439,7 @@ public async Task AWSCreds_DownloadFromCurrentDirectoryOnly_Test()
439439
Region = _connection.Region,
440440
PreSignedUrl = _connection.PreSignedUrl
441441
};
442-
442+
443443
var input = new Input
444444
{
445445
BucketName = _input.BucketName,
@@ -470,7 +470,7 @@ public async Task AWSCreds_ThrowErrorIfNoMatch_Test()
470470
Region = _connection.Region,
471471
PreSignedUrl = _connection.PreSignedUrl
472472
};
473-
473+
474474
var input = new Input
475475
{
476476
BucketName = _input.BucketName,
@@ -497,7 +497,7 @@ public async Task ErrorHandler_ThrowErrorOnFailure_True_WithCustomMessage_Test()
497497
Region = _connection.Region,
498498
PreSignedUrl = _connection.PreSignedUrl
499499
};
500-
500+
501501
var options = new Options
502502
{
503503
ThrowErrorOnFailure = true,
@@ -530,7 +530,7 @@ public async Task ErrorHandler_ThrowErrorOnFailure_True_WithOriginalMessage_Test
530530
Region = _connection.Region,
531531
PreSignedUrl = _connection.PreSignedUrl
532532
};
533-
533+
534534
var options = new Options
535535
{
536536
ThrowErrorOnFailure = true,
@@ -548,7 +548,7 @@ public async Task ErrorHandler_ThrowErrorOnFailure_True_WithOriginalMessage_Test
548548
}
549549
catch (Exception ex)
550550
{
551-
Assert.IsTrue(ex.Message.Contains("The AWS Access Key Id you provided does not exist") ||
551+
Assert.IsTrue(ex.Message.Contains("The AWS Access Key Id you provided does not exist") ||
552552
ex.Message.Contains("InvalidAccessKeyId") ||
553553
ex.Message.Contains("credentials"));
554554
}
@@ -565,7 +565,7 @@ public async Task ErrorHandler_ThrowErrorOnFailure_False_Test()
565565
Region = _connection.Region,
566566
PreSignedUrl = _connection.PreSignedUrl
567567
};
568-
568+
569569
var options = new Options
570570
{
571571
ThrowErrorOnFailure = false,
@@ -579,7 +579,7 @@ public async Task ErrorHandler_ThrowErrorOnFailure_False_Test()
579579
var result = await AmazonS3.DownloadObject(_input, connection, options, default);
580580
Assert.IsFalse(result.Success);
581581
Assert.IsNotNull(result.Error);
582-
Assert.IsTrue(result.Error.Message.Contains("The AWS Access Key Id you provided does not exist") ||
582+
Assert.IsTrue(result.Error.Message.Contains("The AWS Access Key Id you provided does not exist") ||
583583
result.Error.Message.Contains("InvalidAccessKeyId") ||
584584
result.Error.Message.Contains("credentials"));
585585
Assert.IsNotNull(result.Error.AdditionalInfo);

Frends.AmazonS3.DownloadObject/Frends.AmazonS3.DownloadObject/Definitions/Input.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.ComponentModel;
1+
using System.ComponentModel;
22
using System.ComponentModel.DataAnnotations;
33

44
namespace Frends.AmazonS3.DownloadObject.Definitions;
@@ -50,7 +50,7 @@ public class Input
5050
public class Connection
5151
{
5252
/// <summary>
53-
/// Authentication method to use when connecting to AWS S3 bucket.
53+
/// Authentication method to use when connecting to AWS S3 bucket.
5454
/// </summary>
5555
/// <example>AwsCredentials</example>
5656
[DefaultValue(AuthenticationMethods.AwsCredentials)]

Frends.AmazonS3.DownloadObject/Frends.AmazonS3.DownloadObject/Definitions/Options.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace Frends.AmazonS3.DownloadObject.Definitions;
88
public class Options
99
{
1010
/// <summary>
11-
/// Delete S3 source object after download.
12-
/// Subfolders will also be deleted if they are part of the object's key and there are no objects left.
13-
/// Create subfolders manually to make sure they won't be deleted.
11+
/// Delete S3 source object after download.
12+
/// Subfolders will also be deleted if they are part of the object's key and there are no objects left.
13+
/// Create subfolders manually to make sure they won't be deleted.
1414
/// </summary>
1515
/// <example>false</example>
1616
[DefaultValue(false)]
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFrameworks>net8.0</TargetFrameworks>
5-
<Version>3.0.0</Version>
6-
<Authors>Frends</Authors>
7-
<Copyright>Frends</Copyright>
8-
<Company>Frends</Company>
9-
<Product>Frends</Product>
10-
<PackageTags>Frends</PackageTags>
11-
<PackageLicenseExpression>MIT</PackageLicenseExpression>
12-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
13-
<Description>Frends Task for downloading objects from an Amazon S3</Description>
14-
<PackageProjectUrl>https://frends.com/</PackageProjectUrl>
15-
<RepositoryUrl>https://github.com/FrendsPlatform/Frends.AmazonS3</RepositoryUrl>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
5+
<Version>3.0.0</Version>
6+
<Authors>Frends</Authors>
7+
<Copyright>Frends</Copyright>
8+
<Company>Frends</Company>
9+
<Product>Frends</Product>
10+
<PackageTags>Frends</PackageTags>
11+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
12+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
13+
<Description>Frends Task for downloading objects from an Amazon S3</Description>
14+
<PackageProjectUrl>https://frends.com/</PackageProjectUrl>
15+
<RepositoryUrl>https://github.com/FrendsPlatform/Frends.AmazonS3</RepositoryUrl>
1616
</PropertyGroup>
17-
1817
<ItemGroup>
19-
<None Include="FrendsTaskMetadata.json" Pack="true" PackagePath="/">
20-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
21-
</None>
18+
<None Include="FrendsTaskMetadata.json" Pack="true" PackagePath="/">
19+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
20+
</None>
2221
</ItemGroup>
23-
2422
<ItemGroup>
2523
<PackageReference Include="AWSSDK.Core" Version="3.7.400.61" />
2624
<PackageReference Include="AWSSDK.S3" Version="3.7.410.3" />
2725
<PackageReference Include="System.Runtime" Version="4.3.1" />
2826
</ItemGroup>
29-
30-
</Project>
31-
27+
<ItemGroup>
28+
<Content Include="migration.json" PackagePath="/" Pack="true" />
29+
<Content Include="../CHANGELOG.md" PackagePath="/" Pack="true" />
30+
</ItemGroup>
31+
</Project>

Frends.AmazonS3.DownloadObject/Frends.AmazonS3.DownloadObject/Helpers/ErrorHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public static Result Handle(Exception exception, Options options, List<SingleRes
2020
{
2121
if (options.ThrowErrorOnFailure)
2222
{
23-
var errorMessage = !string.IsNullOrWhiteSpace(options.ErrorMessageOnFailure)
24-
? options.ErrorMessageOnFailure
23+
var errorMessage = !string.IsNullOrWhiteSpace(options.ErrorMessageOnFailure)
24+
? options.ErrorMessageOnFailure
2525
: exception.Message;
2626
throw new Exception(errorMessage);
2727
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[
2+
{
3+
"Task": "Frends.AmazonS3.DownloadObject",
4+
"Migrations": [
5+
{
6+
"Version": "3.0.0",
7+
"Description": "Major refactoring - restructured parameters into Input, Connection, and Options classes with improved error handling",
8+
"Migration": [
9+
{
10+
"Type": "Copy",
11+
"Source": "Connection.BucketName",
12+
"Target": "Input.BucketName"
13+
},
14+
{
15+
"Type": "Copy",
16+
"Source": "Connection.S3Directory",
17+
"Target": "Input.SourceDirectory"
18+
},
19+
{
20+
"Type": "Copy",
21+
"Source": "Connection.SearchPattern",
22+
"Target": "Input.SearchPattern"
23+
},
24+
{
25+
"Type": "Copy",
26+
"Source": "Connection.DownloadFromCurrentDirectoryOnly",
27+
"Target": "Input.DownloadFromCurrentDirectoryOnly"
28+
},
29+
{
30+
"Type": "Copy",
31+
"Source": "Connection.DestinationDirectory",
32+
"Target": "Input.TargetDirectory"
33+
},
34+
{
35+
"Type": "Copy",
36+
"Source": "Connection.FileLockedRetries",
37+
"Target": "Options.FileLockedRetries"
38+
},
39+
{
40+
"Type": "Copy",
41+
"Source": "Connection.DeleteSourceObject",
42+
"Target": "Options.DeleteSourceObject"
43+
},
44+
{
45+
"Type": "Copy",
46+
"Source": "Connection.ThrowErrorIfNoMatch",
47+
"Target": "Options.ThrowErrorIfNoMatch"
48+
},
49+
{
50+
"Type": "Copy",
51+
"Source": "Connection.DestinationFileExistsAction",
52+
"Target": "Options.ActionOnExistingFile"
53+
},
54+
{
55+
"Type": "Copy",
56+
"Source": "Connection.AWSCredentials",
57+
"Target": "Connection.AwsCredentials"
58+
},
59+
{
60+
"Type": "Copy",
61+
"Source": "Connection.PreSignedURL",
62+
"Target": "Connection.PreSignedUrl"
63+
},
64+
{
65+
"Type": "Set",
66+
"Target": "Options.ThrowErrorOnFailure",
67+
"Value": "false"
68+
},
69+
{
70+
"Type": "Set",
71+
"Target": "Options.ErrorMessageOnFailure",
72+
"Value": "\"\""
73+
}
74+
]
75+
}
76+
]
77+
}
78+
]

0 commit comments

Comments
 (0)