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

Add standard ObjectStorage support #644

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions build/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
</Target>

<Target Name="RestorePackages" DependsOnTargets="DownloadPaket">
<Exec Command="$(PaketBootstrapper)" />
<Exec Command="$(Paket) install" />
<Exec Command="%22$(PaketBootstrapper)%22" />
<Exec Command="%22$(Paket)%22 install" />
</Target>

<Target Name="DownloadPaket" Condition="!Exists('$(PaketBootstrapper)')">
Expand Down
1,031 changes: 1,031 additions & 0 deletions src/.vs/config/applicationhost.config

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions src/Samples/FSharpCodeSamples/FSharpCodeSamples.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,25 @@
-->
<Import Project="..\..\..\.paket\paket.targets" />
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v3.5'">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v2.0' Or $(TargetFrameworkVersion) == 'v3.0')">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json\lib\net35\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\..\packages\Newtonsoft.Json\lib\net20\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v2.0' Or $(TargetFrameworkVersion) == 'v3.0')">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v3.5'">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json\lib\net20\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\..\packages\Newtonsoft.Json\lib\net35\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0')">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.0'">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll</HintPath>
Expand All @@ -109,7 +109,7 @@
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2')">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3')">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand All @@ -118,16 +118,16 @@
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == 'MonoAndroid') Or ($(TargetFrameworkIdentifier) == 'MonoTouch') Or ($(TargetFrameworkIdentifier) == 'Xamarin.iOS') Or ($(TargetFrameworkIdentifier) == 'Xamarin.Mac') Or ($(TargetFrameworkProfile) == 'Profile7') Or ($(TargetFrameworkProfile) == 'Profile44') Or ($(TargetFrameworkProfile) == 'Profile49') Or ($(TargetFrameworkProfile) == 'Profile78') Or ($(TargetFrameworkProfile) == 'Profile111') Or ($(TargetFrameworkProfile) == 'Profile151') Or ($(TargetFrameworkProfile) == 'Profile259')">
<When Condition="$(TargetFrameworkIdentifier) == '.NETCore'">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json\lib\portable-net45+wp80+win8+wpa81+dnxcore50\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\..\packages\Newtonsoft.Json\lib\netcore45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="($(TargetFrameworkIdentifier) == 'WindowsPhoneApp') Or ($(TargetFrameworkIdentifier) == '.NETCore') Or ($(TargetFrameworkIdentifier) == 'Silverlight' And $(TargetFrameworkVersion) == 'v5.0') Or ($(TargetFrameworkIdentifier) == 'WindowsPhone' And ($(TargetFrameworkVersion) == 'v8.0' Or $(TargetFrameworkVersion) == 'v8.1')) Or ($(TargetFrameworkProfile) == 'Profile5') Or ($(TargetFrameworkProfile) == 'Profile6') Or ($(TargetFrameworkProfile) == 'Profile14') Or ($(TargetFrameworkProfile) == 'Profile19') Or ($(TargetFrameworkProfile) == 'Profile24') Or ($(TargetFrameworkProfile) == 'Profile31') Or ($(TargetFrameworkProfile) == 'Profile32') Or ($(TargetFrameworkProfile) == 'Profile37') Or ($(TargetFrameworkProfile) == 'Profile42') Or ($(TargetFrameworkProfile) == 'Profile47') Or ($(TargetFrameworkProfile) == 'Profile84') Or ($(TargetFrameworkProfile) == 'Profile92') Or ($(TargetFrameworkProfile) == 'Profile102') Or ($(TargetFrameworkProfile) == 'Profile136') Or ($(TargetFrameworkProfile) == 'Profile147') Or ($(TargetFrameworkProfile) == 'Profile157') Or ($(TargetFrameworkProfile) == 'Profile158') Or ($(TargetFrameworkProfile) == 'Profile225') Or ($(TargetFrameworkProfile) == 'Profile240') Or ($(TargetFrameworkProfile) == 'Profile255') Or ($(TargetFrameworkProfile) == 'Profile328') Or ($(TargetFrameworkProfile) == 'Profile336') Or ($(TargetFrameworkProfile) == 'Profile344')">
<When Condition="($(TargetFrameworkIdentifier) == 'WindowsPhoneApp') Or ($(TargetFrameworkIdentifier) == 'Silverlight' And $(TargetFrameworkVersion) == 'v5.0') Or ($(TargetFrameworkIdentifier) == 'WindowsPhone' And ($(TargetFrameworkVersion) == 'v8.0' Or $(TargetFrameworkVersion) == 'v8.1')) Or ($(TargetFrameworkProfile) == 'Profile5') Or ($(TargetFrameworkProfile) == 'Profile6') Or ($(TargetFrameworkProfile) == 'Profile14') Or ($(TargetFrameworkProfile) == 'Profile19') Or ($(TargetFrameworkProfile) == 'Profile24') Or ($(TargetFrameworkProfile) == 'Profile31') Or ($(TargetFrameworkProfile) == 'Profile32') Or ($(TargetFrameworkProfile) == 'Profile37') Or ($(TargetFrameworkProfile) == 'Profile42') Or ($(TargetFrameworkProfile) == 'Profile47') Or ($(TargetFrameworkProfile) == 'Profile84') Or ($(TargetFrameworkProfile) == 'Profile92') Or ($(TargetFrameworkProfile) == 'Profile102') Or ($(TargetFrameworkProfile) == 'Profile136') Or ($(TargetFrameworkProfile) == 'Profile147') Or ($(TargetFrameworkProfile) == 'Profile157') Or ($(TargetFrameworkProfile) == 'Profile158') Or ($(TargetFrameworkProfile) == 'Profile225') Or ($(TargetFrameworkProfile) == 'Profile240') Or ($(TargetFrameworkProfile) == 'Profile255') Or ($(TargetFrameworkProfile) == 'Profile328') Or ($(TargetFrameworkProfile) == 'Profile336') Or ($(TargetFrameworkProfile) == 'Profile344')">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
Expand All @@ -136,18 +136,18 @@
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v3.5'">
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And ($(TargetFrameworkVersion) == 'v1.0' Or $(TargetFrameworkVersion) == 'v1.1' Or $(TargetFrameworkVersion) == 'v1.2' Or $(TargetFrameworkVersion) == 'v1.3' Or $(TargetFrameworkVersion) == 'v1.4' Or $(TargetFrameworkVersion) == 'v1.5' Or $(TargetFrameworkVersion) == 'v1.6')) Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And $(TargetFrameworkVersion) == 'v1.0') Or ($(TargetFrameworkIdentifier) == 'MonoAndroid') Or ($(TargetFrameworkIdentifier) == 'MonoTouch') Or ($(TargetFrameworkIdentifier) == 'Xamarin.iOS') Or ($(TargetFrameworkIdentifier) == 'Xamarin.Mac') Or ($(TargetFrameworkProfile) == 'Profile7') Or ($(TargetFrameworkProfile) == 'Profile44') Or ($(TargetFrameworkProfile) == 'Profile49') Or ($(TargetFrameworkProfile) == 'Profile78') Or ($(TargetFrameworkProfile) == 'Profile111') Or ($(TargetFrameworkProfile) == 'Profile151') Or ($(TargetFrameworkProfile) == 'Profile259')">
<ItemGroup>
<Reference Include="SimpleRESTServices">
<HintPath>..\..\..\packages\SimpleRESTServices\lib\net35\SimpleRESTServices.dll</HintPath>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json\lib\portable-net45+wp80+win8+wpa81+aspnetcore50\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2')">
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3')">
<ItemGroup>
<Reference Include="SimpleRESTServices">
<HintPath>..\..\..\packages\SimpleRESTServices\lib\net40\SimpleRESTServices.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion src/Samples/FSharpCodeSamples/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="6.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding></runtime></configuration>
4 changes: 3 additions & 1 deletion src/corelib/Authentication/AuthenticatedMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage

try
{
return await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
var response = await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
// var contentStr = await response.Content.ReadAsStringAsync();
return response;
}
catch (FlurlHttpException ex)
{
Expand Down
5 changes: 5 additions & 0 deletions src/corelib/Authentication/ServiceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public override int GetHashCode()
/// The Networking service
/// </summary>
public static readonly ServiceType Networking = new ServiceType("network");

/// <summary>
/// The ObjectStorage service
/// </summary>
public static readonly ServiceType ObjectStorage = new ServiceType("object-store");
}

/// <summary>
Expand Down
11 changes: 11 additions & 0 deletions src/corelib/Extensions/FlurlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Flurl.Http;
using OpenStack;
Expand Down Expand Up @@ -132,5 +133,15 @@ public static async Task<HttpResponseMessage> SendAsync(this Task<PreparedReques
PreparedRequest request = await requestTask.ConfigureAwait(false);
return await request.SendAsync().ConfigureAwait(false);
}

/// <summary>
/// Sends the <see cref="HttpResponseHeaders"/>.
/// </summary>
/// <param name="responseTask">A task with returns the response</param>
/// <returns></returns>
public static async Task<HttpResponseHeaders> ReceiveHeaders(this Task<HttpResponseMessage> responseTask)
{
return await Task.FromResult(responseTask.Result.Headers);
}
}
}
92 changes: 91 additions & 1 deletion src/corelib/Flurl/PreparedRequest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Flurl.Http.Configuration;
using Flurl.Http.Content;
using net.openstack.Core;
using OpenStack.ObjectStorage.v1.Metadata;
using OpenStack.ObjectStorage.v1.Serialization;
using OpenStack.Serialization;

// ReSharper disable once CheckNamespace
namespace Flurl.Http
Expand Down Expand Up @@ -69,6 +79,18 @@ public PreparedRequest(Url url, bool autoDispose) : base(url, autoDispose)
/// The optional canellation token which will be used in the request, defaults to None.
/// </summary>
public CancellationToken CancellationToken { get; protected set; }

/// <summary>
/// Apply default timeout to current Request
/// </summary>
/// <param name="defaultTimeout">The timeout to apply.</param>
/// <returns></returns>
public PreparedRequest SettingTimeout(TimeSpan defaultTimeout)
{
Settings.DefaultTimeout = defaultTimeout;
return this;
}


/// <summary>
/// Prepares the client to send a DELETE request
Expand All @@ -79,6 +101,15 @@ public PreparedRequest(Url url, bool autoDispose) : base(url, autoDispose)
CancellationToken = cancellationToken;
return this;
}
/// <summary>
/// Prepares the client to send a DELETE request
/// </summary>
public PreparedRequest PrepareHead(CancellationToken cancellationToken = default(CancellationToken))
{
Verb = HttpMethod.Head;
CancellationToken = cancellationToken;
return this;
}

/// <summary>
/// Prepares the client to send a GET request
Expand All @@ -100,7 +131,7 @@ public PreparedRequest(Url url, bool autoDispose) : base(url, autoDispose)
CancellationToken = cancellationToken;
return this;
}

/// <summary>
/// Prepares the client to send a POST request containing json
/// </summary>
Expand All @@ -112,6 +143,54 @@ public PreparedRequest(Url url, bool autoDispose) : base(url, autoDispose)
return this;
}

/// <summary>
/// Prepares the client to send a POST request containing data in content Header
/// </summary>
/// <param name="formData"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public PreparedRequest PreparePostContentHeader(IEnumerable<KeyValuePair<string, IEnumerable<string>>> formData, CancellationToken cancellationToken = default(CancellationToken))
{
Verb = HttpMethod.Post;

Content = new System.Net.Http.StringContent("");
Content.Headers.Remove("Content-Type");

foreach (var pair in formData)
{
System.Net.Http.Headers.HttpHeaders headerColl;

switch (pair.Key.ToLowerInvariant())
{
case "cache-control":
headerColl = this.HttpClient.DefaultRequestHeaders;
break;
default:
headerColl = this.Content.Headers;
break;
}

headerColl.Add(pair.Key, pair.Value);
}

CancellationToken = cancellationToken;
return this;
}

/// <summary>
/// Prepares the client to send a POST request containing data in content Header
/// </summary>
/// <param name="data"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public PreparedRequest PreparePostContentTextPlain(string data, CancellationToken cancellationToken = default(CancellationToken))
{
Verb = HttpMethod.Post;
Content = new System.Net.Http.StringContent(data);
CancellationToken = cancellationToken;
return this;
}

/// <summary>
/// Prepares the client to send a PUT request containing json
/// </summary>
Expand All @@ -123,6 +202,17 @@ public PreparedRequest(Url url, bool autoDispose) : base(url, autoDispose)
return this;
}

/// <summary>
/// Prepares the client to send a PUT request containing data in stream
/// </summary>
public PreparedRequest PreparePutStream(System.IO.Stream dataStream, CancellationToken cancellationToken = default(CancellationToken))
{
Verb = HttpMethod.Put;
Content = new CapturedStreamContent(dataStream);
CancellationToken = cancellationToken;
return this;
}

/// <summary>
/// Executes the built request
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions src/corelib/ObjectStorage/NamespaceDoc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace OpenStack.ObjectStorage
{
using System.Runtime.CompilerServices;

/// <summary>
/// The <see cref="OpenStack.ObjectStorage"/> namespace defines provider-independent
/// interfaces and implementations for the OpenStack ObjectStorage API.
/// </summary>
[CompilerGenerated]
internal class NamespaceDoc
{
}
}
69 changes: 69 additions & 0 deletions src/corelib/ObjectStorage/v1/BulkDeleteResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using OpenStack.ObjectStorage.v1.Serialization;

namespace OpenStack.ObjectStorage.v1 {

/// <summary>
/// Result of BulkDelete operation.
/// See <see cref="ObjectStorageService.DeleteContainerObjectListAsync(string, IEnumerable{string}, System.Threading.CancellationToken)"/>.
/// </summary>
public class BulkDeleteResult {

/// <summary>
/// Items found
/// </summary>
[JsonProperty("Number Not Found")]
public int? NumberNotFound { get; set; }

/// <summary>
/// Items deleted
/// </summary>
[JsonProperty("Number Deleted")]
public int? NumberDeleted { get; set; }

/// <summary>
/// Response status
/// </summary>
[JsonProperty("Response Status")]
[JsonConverter(typeof(HttpStatusCodeConverter))]
public System.Net.HttpStatusCode ResponseStatus { get; set; }

/// <summary>
/// Response body
/// </summary>
[JsonProperty("Response Body")]
public string ResponseBody { get; set; }

/// <summary>
/// Errors
/// </summary>
[JsonProperty("Errors")]
public ErrorItem[] Errors { get; set; }


/// <summary>
/// Error item
/// </summary>
public class ErrorItem
{

/// <summary>
/// Item fullname
/// </summary>
[JsonProperty("Name")]
public string Name { get; set; }

/// <summary>
/// Error status
/// </summary>
[JsonProperty("Status")]
public string Status { get; set; }
}

}
}
Loading