Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added transfer options to all transfer types. #25

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net462</TargetFrameworks>
<LangVersion>10.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ByteSize" Version="2.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Relativity.Transfer.SDK" Version="2.1.2" />
<PackageReference Include="Spectre.Console" Version="0.48.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="Relativity.Transfer.SDK" Version="2.7.0" />
<PackageReference Include="Spectre.Console" Version="0.49.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<ItemGroup>
<PackageReference Include="ByteSize" Version="2.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Relativity.Transfer.SDK" Version="2.1.2" />
<PackageReference Include="Spectre.Console" Version="0.48.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Relativity.Transfer.SDK" Version="2.7.0" />
<PackageReference Include="Spectre.Console" Version="0.49.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using Relativity.Transfer.SDK.Interfaces.Options;
using Relativity.Transfer.SDK.Interfaces.Paths;
using Relativity.Transfer.SDK.Samples.Core.Attributes;
using Relativity.Transfer.SDK.Samples.Core.Authentication;
Expand Down Expand Up @@ -41,6 +42,12 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
: new DirectoryPath(configuration.DownloadDirectory.Source);
var destination = _pathExtension.EnsureLocalDirectory(configuration.DownloadDirectory.Destination);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var downloadDirectoryOptions = new DownloadDirectoryOptions()
{
MaximumSpeed = default,
GrzegorzSidwa marked this conversation as resolved.
Show resolved Hide resolved
OverwritePolicy = default,
// ...
};
var progressHandler = _progressHandlerFactory.Create();

// The builder follows the Fluent convention, and more options will be added in the future. The only required component (besides the client name)
Expand All @@ -54,7 +61,7 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
_consoleLogger.PrintCreatingTransfer(jobId, source, destination);

var result = await transferClient
.DownloadDirectoryAsync(jobId, source, destination, progressHandler, token)
.DownloadDirectoryAsync(jobId, source, destination, downloadDirectoryOptions, progressHandler, token)
.ConfigureAwait(false);

_consoleLogger.PrintTransferResult(result);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using Relativity.Transfer.SDK.Interfaces.Options;
using Relativity.Transfer.SDK.Interfaces.Paths;
using Relativity.Transfer.SDK.Samples.Core.Attributes;
using Relativity.Transfer.SDK.Samples.Core.Authentication;
Expand Down Expand Up @@ -38,7 +39,13 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
var jobId = configuration.Common.JobId;
var source = new FilePath(configuration.DownloadFile.Source);
var destination = _pathExtension.EnsureLocalDirectory(configuration.DownloadFile.Destination);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var downloadFileOptions = new DownloadFileOptions()
{
MaximumSpeed = default,
OverwritePolicy = default,
// ...
};
var progressHandler = _progressHandlerFactory.Create();

// The builder follows the Fluent convention, and more options will be added in the future. The only required component (besides the client name)
Expand All @@ -52,7 +59,7 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
_consoleLogger.PrintCreatingTransfer(jobId, source, destination);

var result = await transferClient
.DownloadFileAsync(jobId, source, destination, progressHandler, token)
.DownloadFileAsync(jobId, source, destination, downloadFileOptions, progressHandler, token)
.ConfigureAwait(false);

_consoleLogger.PrintTransferResult(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using ByteSizeLib;
using Relativity.Transfer.SDK.Core.ProgressReporting;
using Relativity.Transfer.SDK.Interfaces.Options;
using Relativity.Transfer.SDK.Interfaces.Paths;
using Relativity.Transfer.SDK.Interfaces.ProgressReporting;
using Relativity.Transfer.SDK.Samples.Core.Attributes;
Expand Down Expand Up @@ -47,7 +48,13 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
: string.Empty;
var destination = string.IsNullOrWhiteSpace(configuration.UploadDirectory.Destination)
? _pathExtension.GetDefaultRemoteDirectoryPathForUpload(configuration.Common)
: new DirectoryPath(configuration.UploadDirectory.Destination);
: new DirectoryPath(configuration.UploadDirectory.Destination);
var uploadDirectoryOptions = new UploadDirectoryOptions()
{
MaximumSpeed = default,
OverwritePolicy = default,
// ...
};
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);

// The builder follows the Fluent convention, and more options will be added in the future. The only required component (besides the client name)
Expand All @@ -61,7 +68,7 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
_consoleLogger.PrintCreatingTransfer(jobId, source, destination, additionalLine);

var result = await transferClient
.UploadDirectoryAsync(jobId, source, destination, GetProgressHandler(), default)
.UploadDirectoryAsync(jobId, source, destination, uploadDirectoryOptions, GetProgressHandler(), default)
.ConfigureAwait(false);

PrintTransferSummary(result);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using Relativity.Transfer.SDK.Interfaces.Options;
using Relativity.Transfer.SDK.Interfaces.Paths;
using Relativity.Transfer.SDK.Samples.Core.Attributes;
using Relativity.Transfer.SDK.Samples.Core.Authentication;
Expand Down Expand Up @@ -40,7 +41,13 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
var destination = string.IsNullOrWhiteSpace(configuration.UploadDirectory.Destination)
? _pathExtension.GetDefaultRemoteDirectoryPathForUpload(configuration.Common)
: new DirectoryPath(configuration.UploadDirectory.Destination);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var uploadDirectoryOptions = new UploadDirectoryOptions()
{
MaximumSpeed = default,
OverwritePolicy = default,
// ...
};
var progressHandler = _progressHandlerFactory.Create();

// The builder follows the Fluent convention, and more options will be added in the future. The only required component (besides the client name)
Expand All @@ -54,7 +61,7 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
_consoleLogger.PrintCreatingTransfer(jobId, source, destination);

var result = await transferClient
.UploadDirectoryAsync(jobId, source, destination, progressHandler, token)
.UploadDirectoryAsync(jobId, source, destination, uploadDirectoryOptions, progressHandler, token)
.ConfigureAwait(false);

_consoleLogger.PrintTransferResult(result);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using Relativity.Transfer.SDK.Interfaces.Options;
using Relativity.Transfer.SDK.Interfaces.Paths;
using Relativity.Transfer.SDK.Samples.Core.Attributes;
using Relativity.Transfer.SDK.Samples.Core.Authentication;
Expand Down Expand Up @@ -40,7 +41,13 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
var destination = string.IsNullOrWhiteSpace(configuration.UploadFile.Destination)
? _pathExtension.GetDefaultRemoteDirectoryPathForUpload(configuration.Common)
: new DirectoryPath(configuration.UploadFile.Destination);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var uploadFileOptions = new UploadFileOptions()
{
MaximumSpeed = default,
OverwritePolicy = default,
// ...
};
var progressHandler = _progressHandlerFactory.Create();

// The builder follows the Fluent convention, and more options will be added in the future. The only required component (besides the client name)
Expand All @@ -54,7 +61,7 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
_consoleLogger.PrintCreatingTransfer(jobId, source, destination);

var result = await transferClient
.UploadFileAsync(jobId, source, destination, progressHandler, token)
.UploadFileAsync(jobId, source, destination, uploadFileOptions, progressHandler, token)
.ConfigureAwait(false);

_consoleLogger.PrintTransferResult(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Relativity.Transfer.SDK.Interfaces.Options;
using Relativity.Transfer.SDK.Interfaces.Paths;
using Relativity.Transfer.SDK.Samples.Core.Attributes;
using Relativity.Transfer.SDK.Samples.Core.Authentication;
Expand Down Expand Up @@ -41,7 +42,13 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
var destination = string.IsNullOrWhiteSpace(configuration.UploadFile.Destination)
? _pathExtension.GetDefaultRemoteDirectoryPathForUpload(configuration.Common)
: new DirectoryPath(configuration.UploadFile.Destination);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var uploadListOfItemsOptions = new UploadListOfItemsOptions()
{
MaximumSpeed = default,
OverwritePolicy = default,
// ...
};
var progressHandler = _progressHandlerFactory.Create();

// The builder follows the Fluent convention, and more options will be added in the future. The only required component (besides the client name)
Expand All @@ -58,7 +65,7 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
{
var sources = GetTransferredEntities(configuration.UploadFile.Source);
var result = await transferClient
.UploadItemsAsync(jobId, sources, destination, progressHandler, token)
.UploadItemsAsync(jobId, sources, destination, uploadListOfItemsOptions, progressHandler, token)
.ConfigureAwait(false);

_consoleLogger.PrintTransferResult(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Relativity.Transfer.SDK.Interfaces.Options;
using Relativity.Transfer.SDK.Interfaces.Paths;
using Relativity.Transfer.SDK.Samples.Core.Attributes;
using Relativity.Transfer.SDK.Samples.Core.Authentication;
Expand Down Expand Up @@ -53,6 +54,12 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
var jobId = configuration.Common.JobId;
var source = new DirectoryPath(configuration.UploadDirectoryByWorkspaceId.Source);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var uploadDirectoryOptions = new UploadDirectoryOptions()
{
MaximumSpeed = default,
OverwritePolicy = default,
// ...
};
var progressHandler = _progressHandlerFactory.Create();

// Get list of file shares by workspace ID. The association is based on Resource Pool assigned to the workspace.
Expand All @@ -76,7 +83,7 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
_consoleLogger.PrintCreatingTransfer(jobId, source, destination);

var result = await transferClient
.UploadDirectoryAsync(jobId, source, destination, progressHandler, token)
.UploadDirectoryAsync(jobId, source, destination, uploadDirectoryOptions, progressHandler, token)
.ConfigureAwait(false);

_consoleLogger.PrintTransferResult(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading;
using System.Threading.Tasks;
using Relativity.Transfer.SDK.Interfaces.Authentication;
using Relativity.Transfer.SDK.Interfaces.Options;
using Relativity.Transfer.SDK.Interfaces.Paths;
using Relativity.Transfer.SDK.Samples.Core.Attributes;
using Relativity.Transfer.SDK.Samples.Core.Authentication;
Expand Down Expand Up @@ -42,8 +43,14 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
? _pathExtension.GetDefaultRemoteDirectoryPathForDownload(configuration.Common)
: new DirectoryPath(configuration.DownloadDirectory.Source);
var destination = _pathExtension.EnsureLocalDirectory(configuration.DownloadDirectory.Destination);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var progressHandler = _progressHandlerFactory.Create();
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var downloadDirectoryOptions = new DownloadDirectoryOptions()
{
MaximumSpeed = default,
OverwritePolicy = default,
// ...
};
var progressHandler = _progressHandlerFactory.Create();

await RegisterDownloadJobAsync(authenticationProvider, jobId, source).ConfigureAwait(false);

Expand All @@ -59,7 +66,7 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
_consoleLogger.PrintCreatingTransfer(jobId, source, destination);

var result = await transferClient
.DownloadDirectoryAsync(jobId, destination, progressHandler, token)
.DownloadDirectoryAsync(jobId, destination, downloadDirectoryOptions, progressHandler, token)
.ConfigureAwait(false);

_consoleLogger.PrintTransferResult(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading;
using System.Threading.Tasks;
using Relativity.Transfer.SDK.Interfaces.Authentication;
using Relativity.Transfer.SDK.Interfaces.Options;
using Relativity.Transfer.SDK.Interfaces.Paths;
using Relativity.Transfer.SDK.Samples.Core.Attributes;
using Relativity.Transfer.SDK.Samples.Core.Authentication;
Expand Down Expand Up @@ -43,8 +44,14 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
string.IsNullOrWhiteSpace(configuration.DownloadDirectoryBasedOnExistingJob.FirstDestination)
? _pathExtension.GetDefaultRemoteDirectoryPathForUpload(configuration.Common)
: new DirectoryPath(configuration.DownloadDirectoryBasedOnExistingJob.FirstDestination);
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var progressHandler = _progressHandlerFactory.Create();
var authenticationProvider = _relativityAuthenticationProviderFactory.Create(configuration.Common);
var uploadDirectoryOptions = new UploadDirectoryOptions()
{
MaximumSpeed = default,
OverwritePolicy = default,
// ...
};
var progressHandler = _progressHandlerFactory.Create();

// The builder follows the Fluent convention, and more options will be added in the future. The only required component (besides the client name)
// is the authentication provider - a provided one that utilizes an OAuth-based approach has been provided, but the custom implementation can be created.
Expand All @@ -58,7 +65,7 @@ public async Task ExecuteAsync(Configuration configuration, CancellationToken to
_consoleLogger.PrintCreatingTransfer(uploadJobId, uploadSource, uploadDestination);

var uploadResult = await transferFullPathClient
.UploadDirectoryAsync(uploadJobId, uploadSource, uploadDestination, progressHandler, token)
.UploadDirectoryAsync(uploadJobId, uploadSource, uploadDestination, uploadDirectoryOptions, progressHandler, token)
.ConfigureAwait(false);

_consoleLogger.PrintTransferResult(uploadResult, "Upload transfer has finished:", false);
Expand All @@ -78,10 +85,17 @@ await RegisterDownloadJobFromExistingJobAsync(authenticationProvider, downloadJo
.WithStagingExplorerContext()
.Build();

_consoleLogger.PrintCreatingTransfer(downloadJobId, uploadSource, downloadDestination);

var downloadResult = await transferJobClient
.DownloadDirectoryAsync(downloadJobId, downloadDestination, progressHandler, token)
_consoleLogger.PrintCreatingTransfer(downloadJobId, uploadSource, downloadDestination);

var downloadDirectoryOptions = new DownloadDirectoryOptions()
{
MaximumSpeed = default,
OverwritePolicy = default,
// ...
};

var downloadResult = await transferJobClient
.DownloadDirectoryAsync(downloadJobId, downloadDestination, downloadDirectoryOptions, progressHandler, token)
.ConfigureAwait(false);

_consoleLogger.PrintTransferResult(downloadResult, "Download transfer has finished:");
Expand Down
Loading