-
Notifications
You must be signed in to change notification settings - Fork 6
Share Project support for BaseSpace SDK #39
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ | |
<HintPath>..\packages\Common.Logging.2.1.2\lib\net40\Common.Logging.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Illumina.TerminalVelocity"> | ||
<HintPath>..\packages\TerminalVelocity.Sharp.1.0.0.72\lib\net40\Illumina.TerminalVelocity.dll</HintPath> | ||
<HintPath>..\..\BrightSpark\output\bin\Illumina.TerminalVelocity.dll</HintPath> | ||
</Reference> | ||
<Reference Include="ServiceStack.Common, Version=3.9.71.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
|
@@ -98,6 +98,7 @@ | |
<Compile Include="Interfaces\IRequest.cs" /> | ||
<Compile Include="Interfaces\IRequestOptions.cs" /> | ||
<Compile Include="Interfaces\IWebClient.cs" /> | ||
<Compile Include="ServiceModels\Request\CreateProjectShareRequest.cs" /> | ||
<Compile Include="ServiceModels\Request\ListLibraryContainersRequest.cs" /> | ||
<Compile Include="ServiceModels\Request\ListSampleLibrariesFromRunRequest.cs" /> | ||
<Compile Include="ServiceModels\Request\AbstractRequest.cs" /> | ||
|
@@ -179,6 +180,7 @@ | |
<Compile Include="ServiceModels\Response\ListSampleLibrariesResponse.cs" /> | ||
<Compile Include="ServiceModels\Response\ListSupportedLibraryPrepKitsResponse.cs" /> | ||
<Compile Include="ServiceModels\Response\PlannedRunReadyResponse.cs" /> | ||
<Compile Include="ServiceModels\Response\ProjectShareResponse.cs" /> | ||
<Compile Include="ServiceModels\Response\SearchResponse.cs" /> | ||
<Compile Include="ServiceModels\Response\SetPropertiesResponse.cs" /> | ||
<Compile Include="ServiceModels\Response\CreateAppSessionLogsResponse.cs" /> | ||
|
@@ -228,6 +230,7 @@ | |
<Compile Include="Types\Agreement.cs" /> | ||
<Compile Include="Types\ApiCategoryAttribute.cs" /> | ||
<Compile Include="Types\ApiMeta.cs" /> | ||
<Compile Include="Types\Invite.cs" /> | ||
<Compile Include="Types\PlannedRun.cs" /> | ||
<Compile Include="Types\SourceLibrary.cs" /> | ||
<Compile Include="Types\PropertyContentMap.cs" /> | ||
|
@@ -264,17 +267,7 @@ | |
<Compile Include="Types\Variant.cs" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here please remove changes to the nuget |
||
<Compile Include="Types\VerificationCode.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="BaseSpace.SDK.nuspec"> | ||
<SubType>Designer</SubType> | ||
</None> | ||
<None Include="packages.config"> | ||
<SubType>Designer</SubType> | ||
</None> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> | ||
<!--<Import Project="$(SolutionDir)\.nuget\nuget.targets" />--> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
<language>en-US</language> | ||
<copyright>illumina 2013 and contributors</copyright> | ||
<dependencies> | ||
<dependency id="TerminalVelocity.Sharp"/> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please remove this change too? |
||
</dependencies> | ||
</metadata> | ||
<files> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,28 +18,28 @@ public class FileUpload | |
protected IClientSettings ClientSettings { get; set; } | ||
protected IRequestOptions Options { get; set; } | ||
protected ILog Logger = LogManager.GetCurrentClassLogger(); | ||
|
||
public FileUpload(IWebClient webClient, IClientSettings settings, IRequestOptions options) | ||
{ | ||
WebClient = webClient; | ||
ClientSettings = settings; | ||
Options = options; | ||
} | ||
|
||
public virtual TResult UploadFile<TResult>(FileUploadRequestBase<TResult> request) | ||
where TResult : FileResponse | ||
{ | ||
Logger.DebugFormat("numthreads {0}", request.ThreadCount); | ||
TResult file = null; | ||
public virtual TResult UploadFile<TResult>(FileUploadRequestBase<TResult> request) | ||
where TResult : FileResponse | ||
{ | ||
Logger.DebugFormat("numthreads {0}", request.ThreadCount); | ||
TResult file = null; | ||
|
||
RetryLogic.DoWithRetry(ClientSettings.RetryAttempts, string.Format("Uploading file {0}", request.FileInfo.Name), | ||
() => | ||
{ | ||
{ | ||
request.MultiPart = request.FileInfo.Length >= ClientSettings.FileUploadMultipartSizeThreshold; | ||
|
||
file = request.MultiPart.Value ? | ||
UploadFile_MultiPart(request) : | ||
WebClient.Send(request); | ||
WebClient.Send(request); | ||
}, Logger, retryHandler: | ||
(exc) => | ||
{ | ||
|
@@ -59,14 +59,14 @@ public virtual TResult UploadFile<TResult>(FileUploadRequestBase<TResult> reques | |
return file; | ||
} | ||
|
||
protected virtual TResult UploadFile_MultiPart<TResult>(FileUploadRequestBase<TResult> request) | ||
where TResult : FileResponse | ||
protected virtual TResult UploadFile_MultiPart<TResult>(FileUploadRequestBase<TResult> request) | ||
where TResult : FileResponse | ||
{ | ||
Logger.InfoFormat("File Upload: {0}: Initiating multipart upload", request.FileInfo.Name); | ||
|
||
var fileUploadresp = WebClient.Send(request); | ||
var fileUploadresp = WebClient.Send(request); | ||
|
||
var server = ClientSettings.BaseSpaceApiUrl.TrimEnd('/'); | ||
var server = ClientSettings.BaseSpaceApiUrl.TrimEnd('/'); | ||
|
||
uint chunkSize = ClientSettings.FileUploadMultipartChunkSize; | ||
|
||
|
@@ -125,7 +125,7 @@ protected virtual TResult UploadFile_MultiPart<TResult>(FileUploadRequestBase<TR | |
})); | ||
|
||
bool success = errorSignal.WaitOne(0) == false; | ||
|
||
var status = success ? FileUploadStatus.complete : FileUploadStatus.aborted; | ||
|
||
var statusReq = new FileRequestPost<TResult> | ||
|
@@ -143,7 +143,7 @@ protected virtual TResult UploadFile_MultiPart<TResult>(FileUploadRequestBase<TR | |
|
||
|
||
static object _syncRead = new object(); | ||
|
||
protected virtual void UploadPart(string fullUrl, FileInfo fileToUpload, long startPosition, int partNumber, ManualResetEvent errorSignal, string partDescription, uint chunkSize) | ||
{ | ||
RetryLogic.DoWithRetry(ClientSettings.RetryAttempts, string.Format("Uploading part {0} of {1}", partDescription, fileToUpload.Name), | ||
|
@@ -159,9 +159,9 @@ protected virtual void UploadPart(string fullUrl, FileInfo fileToUpload, long st | |
{ | ||
data = BufferPool.GetChunk((int)chunkSize); | ||
|
||
var authentication = ClientSettings.Authentication; | ||
authentication.UpdateHttpHeader(wc.Headers, new Uri(fullUrl), "PUT"); | ||
var authentication = ClientSettings.Authentication; | ||
authentication.UpdateHttpHeader(wc.Headers, new Uri(fullUrl), "PUT"); | ||
|
||
int actualSize; | ||
int desiredSize = (int)Math.Min(fileToUpload.Length - startPosition, chunkSize); | ||
lock (_syncRead) // avoid thrashing the disk | ||
|
@@ -196,18 +196,33 @@ public static int NumFileUploadParts(FileInfo file) | |
} | ||
|
||
private class BSWebClient : WebClient | ||
{ | ||
//TODO: Doesnt seem right? Need refactor? | ||
// const int CONNECTION_LIMIT = 16; | ||
protected override WebRequest GetWebRequest(Uri address) | ||
{ | ||
var request = base.GetWebRequest(address) as HttpWebRequest; | ||
|
||
if (request != null && request.ServicePoint.ConnectionLimit < 20) | ||
request.ServicePoint.ConnectionLimit = 10000; //Note: Is this changing global value? | ||
|
||
return request; | ||
} | ||
} | ||
{ | ||
//TODO: Doesnt seem right? Need refactoring? | ||
// const int CONNECTION_LIMIT = 16; | ||
protected override WebRequest GetWebRequest(Uri address) | ||
{ | ||
var request = base.GetWebRequest(address) as HttpWebRequest; | ||
|
||
if (request != null && request.ServicePoint.ConnectionLimit < 20) | ||
request.ServicePoint.ConnectionLimit = 10000; //Note: Is this changing global value? | ||
|
||
// Workaround to support slow internet connections. | ||
// On very slow internet connections (specifically between the client and the BaseSpace API server), | ||
// multi-part file uploads tend to fail due to a request timeout. | ||
if (request != null) | ||
{ | ||
// Set the timeout to 10 min (vs default 100 sec). | ||
// This setting was confirmed to work for the minimum upload part size of 5 MB | ||
// on connections with sustainable upload speeds of 20 KB/s and higher. | ||
// Technically, this timeout should be tied to the configured part size, | ||
// but cursory tests demonstrated that for larger part sizes greater timeouts | ||
// start inducing errors (500 in particular) on the server side. | ||
request.Timeout = 600000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you make this change into a different pull request? I feel it is unrelated to sharing api There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The pull request was not intended to be merged directly, just the ideas for On Fri, Apr 24, 2015 at 4:50 PM, adamnation [email protected]
|
||
request.ReadWriteTimeout = request.Timeout; | ||
} | ||
|
||
return request; | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Illumina.BaseSpace.SDK.ServiceModels | ||
{ | ||
public enum SharePermissions | ||
{ | ||
Read, | ||
Write, | ||
Own | ||
} | ||
|
||
[DataContract] | ||
public class CreateProjectShareRequest : AbstractResourceRequest<ProjectShareResponse> | ||
{ | ||
private const string ReadPermission = "READ"; | ||
private const string WritePermission = "WRITE"; | ||
private const string OwnerPermission = "OWN"; | ||
|
||
public CreateProjectShareRequest(string id, string email, string permission, | ||
string description = "") : base(id) | ||
{ | ||
if (permission != ReadPermission || permission != WritePermission || permission!=OwnerPermission) | ||
throw new ArgumentException("Permission must be either READ, WRITE or OWN"); | ||
Permission = permission; | ||
CommonConstruct(id, email, description); | ||
} | ||
|
||
public CreateProjectShareRequest(string id, string email, SharePermissions permission, | ||
string description = "") : base(id) | ||
{ | ||
CommonConstruct(id, email, description); | ||
switch (permission) | ||
{ | ||
case SharePermissions.Read: | ||
Permission = ReadPermission; | ||
break; | ||
case SharePermissions.Write: | ||
Permission = WritePermission; | ||
break; | ||
case SharePermissions.Own: | ||
Permission = OwnerPermission; | ||
break; | ||
} | ||
} | ||
|
||
private void CommonConstruct(string id, string email, string description) | ||
{ | ||
if (string.IsNullOrEmpty(id)) | ||
throw new ArgumentException("You must provide an id"); | ||
if (string.IsNullOrEmpty(email) || !email.Contains("@")) | ||
throw new ArgumentException("You must provide an id"); | ||
if (description == null) | ||
description = string.Empty; | ||
Id = id; | ||
Email = email; | ||
Description = description; | ||
HttpMethod = HttpMethods.POST; | ||
} | ||
|
||
[DataMember] | ||
public string Email { get; set; } | ||
[DataMember] | ||
public string Permission { get; set; } | ||
[DataMember] | ||
public string Description { get; set; } | ||
|
||
protected override string GetUrl() | ||
{ | ||
return string.Format("{0}/project/{1}/invites", Version, Id); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Illumina.BaseSpace.SDK.Types; | ||
|
||
namespace Illumina.BaseSpace.SDK.ServiceModels | ||
{ | ||
public class ProjectShareResponse : ApiResponse<Invite> | ||
{ | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Illumina.BaseSpace.SDK.Types | ||
{ | ||
[DataContract(Name = "Invite")] | ||
public class InviteCompact : AbstractResource | ||
{ | ||
[DataMember(IsRequired = true)] | ||
public override string Id { get; set; } | ||
|
||
[DataMember] | ||
public override Uri Href { get; set; } | ||
|
||
[DataMember] | ||
public UserCompact UserInvited { get; set; } | ||
|
||
[DataMember] | ||
public string EmailInvited { get; set; } | ||
|
||
|
||
public string Type | ||
{ | ||
get { return PropertyTypes.INVITE; } | ||
} | ||
public override string ToString() | ||
{ | ||
return string.Format("Href: {0}; Id: {1}", Href, Id); | ||
} | ||
} | ||
|
||
[DataContract] | ||
public class Invite : InviteCompact | ||
{ | ||
[DataMember] | ||
public Uri HrefInvite { get; set; } | ||
|
||
[DataMember] | ||
public string Status { get; set; } | ||
|
||
[DataMember] | ||
public DateTime DateCreated { get; set; } | ||
[DataMember] | ||
public DateTime DateModified { get; set; } | ||
|
||
[DataMember] | ||
public string Permission { get; set; } | ||
|
||
[DataMember] | ||
public bool HasCollaborators { get; set; } | ||
|
||
[DataMember] | ||
public IContentReference<IAbstractResource>[] References { get; set; } | ||
|
||
[DataMember] | ||
public long TotalSize { get; set; } | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you get rid of this change?