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

Made some refactoring, fixed some potential issues #8

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
54 changes: 54 additions & 0 deletions OpenStack.Nova/OpenStack.Nova.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9B1E8C12-D57A-4DE7-BE74-E6063E98D433}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>OpenStack.Nova</RootNamespace>
<AssemblyName>OpenStack.Nova</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Net" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="AbstractClient.cs" />
<Compile Include="ClientException.cs" />
<Compile Include="AuthResponse.cs" />
<Compile Include="AccountResponse.cs" />
<Compile Include="ContainerResponse.cs" />
<Compile Include="ObjectResponse.cs" />
<Compile Include="IHttpRequestFactory.cs" />
<Compile Include="IHttpRequest.cs" />
<Compile Include="IHttpResponse.cs" />
<Compile Include="HttpRequest.cs" />
<Compile Include="HttpResponse.cs" />
<Compile Include="HttpRequestFactory.cs" />
<Compile Include="NovaClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
18 changes: 18 additions & 0 deletions OpenStack.Swift.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version='1.0'?>
<package xmlns='http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'>
<metadata>
<id>OpenStack.Swift</id>
<version>1.0.2</version>
<title>OpenStack.Swift</title>
<authors>Conrad Weidenkeller</authors>
<description>A light http wrapper for the swift API implemented in C#</description>
<licenseUrl>http://github.com/cweidenkeller/csharp-swift/blob/master/LICENSE</licenseUrl>
<projectUrl>http://github.com/edwardt/OpenStack.Swift.git</projectUrl>
<copyright>Copyright (c) 2011, 2012, Conrad Weidenkeller. All Rights Reserved</copyright>
<owners>Conrad Weidenkeller, Jason Meridth, Edward Tsang</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
</metadata>
<files>
<file src='src\OpenStack.Swift\bin\Debug\OpenStack.Swift.dll' target='lib\net40\OpenStack.Swift.dll'/>
</files>
</package>
67 changes: 67 additions & 0 deletions OpenStack.Swift.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenStack.Swift.Unit.Tests", "tests\OpenStack.Swift.Unit.Tests\OpenStack.Swift.Unit.Tests.csproj", "{2DA4B272-55B0-4D72-89EB-C80327A2E003}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenStack.Swift", "src\OpenStack.Swift\OpenStack.Swift.csproj", "{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenStack.Swift.Functional.Tests", "tests\OpenStack.Swift.Functional.Tests\OpenStack.Swift.Functional.Tests.csproj", "{42BB3EBC-5619-42E2-A61E-9330844D69E1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{01E70F4A-74B1-4665-9331-F5E2BF9F5503}"
ProjectSection(SolutionItems) = preProject
csharp-swift.nuspec = csharp-swift.nuspec
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
Default|Any CPU = Default|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2DA4B272-55B0-4D72-89EB-C80327A2E003}.Debug|x86.ActiveCfg = Debug|Any CPU
{2DA4B272-55B0-4D72-89EB-C80327A2E003}.Debug|x86.Build.0 = Debug|Any CPU
{2DA4B272-55B0-4D72-89EB-C80327A2E003}.Release|x86.ActiveCfg = Release|Any CPU
{2DA4B272-55B0-4D72-89EB-C80327A2E003}.Release|x86.Build.0 = Release|Any CPU
{42BB3EBC-5619-42E2-A61E-9330844D69E1}.Debug|x86.ActiveCfg = Debug|Any CPU
{42BB3EBC-5619-42E2-A61E-9330844D69E1}.Debug|x86.Build.0 = Debug|Any CPU
{42BB3EBC-5619-42E2-A61E-9330844D69E1}.Release|x86.ActiveCfg = Release|Any CPU
{42BB3EBC-5619-42E2-A61E-9330844D69E1}.Release|x86.Build.0 = Release|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Debug|x86.ActiveCfg = Debug|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Debug|x86.Build.0 = Debug|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Release|x86.ActiveCfg = Release|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = tests\OpenStack.Swift.Unit.Tests\OpenStack.Swift.Unit.Tests.csproj
Policies = $0
$0.DotNetNamingPolicy = $1
$1.DirectoryNamespaceAssociation = None
$1.ResourceNamePolicy = FileFormatDefault
$0.TextStylePolicy = $2
$2.inheritsSet = null
$2.scope = text/x-csharp
$0.CSharpFormattingPolicy = $3
$3.inheritsSet = Mono
$3.inheritsScope = text/x-csharp
$3.scope = text/x-csharp
$0.TextStylePolicy = $4
$4.inheritsSet = null
$4.scope = application/xml
$0.XmlFormattingPolicy = $5
$5.inheritsSet = Mono
$5.inheritsScope = application/xml
$5.scope = application/xml
$0.StandardHeader = $6
$6.Text =
$6.IncludeInNewFiles = True
$0.VersionControlPolicy = $7
$7.inheritsSet = Mono
version = 1.0
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
43 changes: 37 additions & 6 deletions csharp-swift.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
csharp-swift.nuspec = csharp-swift.nuspec
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenStack.Nova", "OpenStack.Nova\OpenStack.Nova.csproj", "{9B1E8C12-D57A-4DE7-BE74-E6063E98D433}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Expand All @@ -22,20 +24,49 @@ Global
{2DA4B272-55B0-4D72-89EB-C80327A2E003}.Debug|x86.Build.0 = Debug|Any CPU
{2DA4B272-55B0-4D72-89EB-C80327A2E003}.Release|x86.ActiveCfg = Release|Any CPU
{2DA4B272-55B0-4D72-89EB-C80327A2E003}.Release|x86.Build.0 = Release|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Debug|x86.ActiveCfg = Debug|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Debug|x86.Build.0 = Debug|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Release|x86.ActiveCfg = Release|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Release|x86.Build.0 = Release|Any CPU
{42BB3EBC-5619-42E2-A61E-9330844D69E1}.Debug|x86.ActiveCfg = Debug|Any CPU
{42BB3EBC-5619-42E2-A61E-9330844D69E1}.Debug|x86.Build.0 = Debug|Any CPU
{42BB3EBC-5619-42E2-A61E-9330844D69E1}.Release|x86.ActiveCfg = Release|Any CPU
{42BB3EBC-5619-42E2-A61E-9330844D69E1}.Release|x86.Build.0 = Release|Any CPU
{9B1E8C12-D57A-4DE7-BE74-E6063E98D433}.Debug|x86.ActiveCfg = Debug|Any CPU
{9B1E8C12-D57A-4DE7-BE74-E6063E98D433}.Debug|x86.Build.0 = Debug|Any CPU
{9B1E8C12-D57A-4DE7-BE74-E6063E98D433}.Release|x86.ActiveCfg = Release|Any CPU
{9B1E8C12-D57A-4DE7-BE74-E6063E98D433}.Release|x86.Build.0 = Release|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Debug|x86.ActiveCfg = Debug|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Debug|x86.Build.0 = Debug|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Release|x86.ActiveCfg = Release|Any CPU
{FB1A48EB-3384-4092-BE4C-6641AEFCBB26}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = tests\OpenStack.Swift.Unit.Tests\OpenStack.Swift.Unit.Tests.csproj
Policies = $0
$0.DotNetNamingPolicy = $1
$1.DirectoryNamespaceAssociation = None
$1.ResourceNamePolicy = FileFormatDefault
$0.TextStylePolicy = $2
$2.inheritsSet = null
$2.scope = text/x-csharp
$0.CSharpFormattingPolicy = $3
$3.inheritsSet = Mono
$3.inheritsScope = text/x-csharp
$3.scope = text/x-csharp
$0.TextStylePolicy = $4
$4.inheritsSet = null
$4.scope = application/xml
$0.XmlFormattingPolicy = $5
$5.inheritsSet = Mono
$5.inheritsScope = application/xml
$5.scope = application/xml
$0.StandardHeader = $6
$6.Text =
$6.IncludeInNewFiles = True
$0.VersionControlPolicy = $7
$7.inheritsSet = Mono
version = 1.0
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
30 changes: 30 additions & 0 deletions src/OpenStack.Swift/AbstractClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace OpenStack.Swift
{
using System;
using System.IO;
using System.Collections.Generic;

/// <summary>
/// I client.
/// </summary>
public abstract class Client
{
public abstract void DisableSSLCertificateValidation();
public abstract AuthResponse GetAuth(string url, string user, string key, Dictionary<string, string> headers, Dictionary<string, string> query, bool snet);
public abstract AccountResponse GetAccount(string url, string token, Dictionary<string, string> headers, Dictionary<string, string> query, bool full_listing);
public abstract AccountResponse HeadAccount(string url, string token, Dictionary<string, string> headers, Dictionary<string, string> query);
public abstract AccountResponse PostAccount(string url, string token, Dictionary<string, string> headers, Dictionary<string, string> query);
public abstract ContainerResponse GetContainer(string url, string token, string container, Dictionary<string, string> headers, Dictionary<string, string> query, bool full_listing);
public abstract ContainerResponse HeadContainer(string url, string token, string container, Dictionary<string, string> headers, Dictionary<string, string> query);
public abstract ContainerResponse PostContainer(string url, string token, string container, Dictionary<string, string> headers, Dictionary<string, string> query);
public abstract ContainerResponse PutContainer(string url, string token, string container, Dictionary<string, string> headers, Dictionary<string, string> query);
public abstract ContainerResponse DeleteContainer(string url, string token, string container, Dictionary<string, string> headers, Dictionary<string, string> query);
public abstract ObjectResponse GetObject(string url, string token, string container, string name, Dictionary<string, string> headers, Dictionary<string, string> query);
public abstract ObjectResponse HeadObject(string url, string token, string container, string name, Dictionary<string, string> headers, Dictionary<string, string> query);
public abstract ObjectResponse PostObject(string url, string token, string container, string name, Dictionary<string, string> headers, Dictionary<string, string> query);
public abstract ObjectResponse PutObject(string url, string token, string container, string name, Stream contents, Dictionary<string, string> headers, Dictionary<string, string> query);
public abstract ObjectResponse DeleteObject(string url, string token, string container, string name, Dictionary<string, string> headers, Dictionary<string, string> query);

}
}

38 changes: 38 additions & 0 deletions src/OpenStack.Swift/AccountResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace OpenStack.Swift
{
using System;
using System.Collections.Generic;
using System.IO;
/// <summary>
/// An object containing AccountResponse information
/// </summary>
public class AccountResponse : BaseResponse
{

/// <summary>
/// The container list returned if a get request otherwise this will be null
/// </summary>
public readonly List<Dictionary<string, string>> Containers;
/// <summary>
/// Initializes a new instance of the <see><cref>Openstack.Swift.AccountResponse</cref></see> class.
/// </summary>
/// <param name='headers'>
/// The response headers
/// </param>
/// <param name='reason'>
/// The status description
/// </param>
/// <param name='status'>
/// The status code of the request
/// </param>
/// <param name='containers'>
/// The Container List if one is needed null otherwise
/// </param>
public AccountResponse(Dictionary<string, string> headers, string reason, int status, List<Dictionary<string, string>> containers):
base(headers, status, reason)
{
Containers = containers;
}
}
}

4 changes: 2 additions & 2 deletions src/OpenStack.Swift/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
// Change them to the values specific to your project.

[assembly: AssemblyTitle("OpenStack.Swift")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Basic OpenStack Swift Web Client")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("cweidenkeller")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyCulture("en")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
Expand Down
31 changes: 31 additions & 0 deletions src/OpenStack.Swift/AuthResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace OpenStack.Swift
{
using System;
using System.Collections.Generic;
using System.IO;
/// <summary>
/// An Object that holds auth information
/// </summary>
public class AuthResponse : BaseResponse
{

/// <summary>
/// Initializes a new instance of the <see><cref>Openstack.Swift.AuthResponse</cref></see> class.
/// </summary>
/// <param name='headers'>
/// Response headers
/// </param>
/// <param name='reason'>
/// Response status description.
/// </param>
/// <param name='status'>
/// Response status from the server.
/// </param>
public AuthResponse(Dictionary<string, string> headers, string reason, int status) :
base(headers, status, reason)

{
}
}
}

29 changes: 29 additions & 0 deletions src/OpenStack.Swift/BaseResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace OpenStack.Swift
{
using System;
using System.Collections.Generic;

public class BaseResponse
{
/// <summary>
/// Basic response headers
/// </summary>
public readonly Dictionary<string, string> Headers;
/// <summary>
/// response status from the server.
/// </summary>
public readonly int Status;
/// <summary>
/// The status description from the server.
/// </summary>
public readonly string Reason;

public BaseResponse (Dictionary<string,string> headers, int status, string reason)
{
Headers = headers;
Status = status;
Reason = reason;
}
}
}

Loading