From dc3288ab8d15554a335483ff92cf21c117263b64 Mon Sep 17 00:00:00 2001 From: Wayne Foley Date: Thu, 1 May 2014 10:45:20 -0700 Subject: [PATCH] Adding example code to show how to build a new service client from the ground up. Updated the .gitignore file to do a better job of ignoring bin,obj, and package folders. Partially implements blueprint initial-docs Change-Id: Ia5225027f5ad2972facabbbe5458b814ef09b6be --- .gitignore | 11 +-- .../CustomServiceClientExample/App.config | 6 ++ .../CustomServiceClientExample.csproj | 78 +++++++++++++++++++ .../EchoPocoClient.cs | 41 ++++++++++ .../EchoPocoClientFactory.cs | 28 +++++++ .../EchoResponse.cs | 31 ++++++++ .../EchoRestClient.cs | 45 +++++++++++ .../EchoRestClientFactory.cs | 28 +++++++ .../EchoServiceClient.cs | 39 ++++++++++ .../EchoServiceClientDefinition.cs | 49 ++++++++++++ .../EchoServiceRegistrar.cs | 32 ++++++++ .../IEchoPocoClient.cs | 25 ++++++ .../IEchoPocoClientFactory.cs | 25 ++++++ .../IEchoRestClient.cs | 26 +++++++ .../IEchoRestClientFactory.cs | 25 ++++++ .../IEchoServiceClient.cs | 26 +++++++ .../CustomServiceClientExample/Program.cs | 55 +++++++++++++ .../Properties/AssemblyInfo.cs | 36 +++++++++ OpenStack/Examples/Examples.sln | 8 +- 19 files changed, 605 insertions(+), 9 deletions(-) create mode 100644 OpenStack/Examples/CustomServiceClientExample/App.config create mode 100644 OpenStack/Examples/CustomServiceClientExample/CustomServiceClientExample.csproj create mode 100644 OpenStack/Examples/CustomServiceClientExample/EchoPocoClient.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/EchoPocoClientFactory.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/EchoResponse.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/EchoRestClient.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/EchoRestClientFactory.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/EchoServiceClient.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/EchoServiceClientDefinition.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/EchoServiceRegistrar.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/IEchoPocoClient.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/IEchoPocoClientFactory.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/IEchoRestClient.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/IEchoRestClientFactory.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/IEchoServiceClient.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/Program.cs create mode 100644 OpenStack/Examples/CustomServiceClientExample/Properties/AssemblyInfo.cs diff --git a/.gitignore b/.gitignore index dddb274..d22210f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,13 +2,8 @@ # This .gitignore file was automatically created by Microsoft(R) Visual Studio. ################################################################################ -/Openstack/Openstack/obj -/Openstack/Openstack.Common/obj -/Openstack/Openstack.Test/obj -/Openstack/Bin *.user *.suo -/Openstack/packages -/Openstack/Openstack/obj -/Openstack/Openstack.Common/obj -/Openstack/Openstack.Test/obj +packages/ +obj/ +bin/ \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/App.config b/OpenStack/Examples/CustomServiceClientExample/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/CustomServiceClientExample.csproj b/OpenStack/Examples/CustomServiceClientExample/CustomServiceClientExample.csproj new file mode 100644 index 0000000..ce6072b --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/CustomServiceClientExample.csproj @@ -0,0 +1,78 @@ + + + + + Debug + AnyCPU + {83B16A76-A3DF-42E5-95A6-5BBE41FC7854} + Exe + Properties + CustomServiceClientExample + CustomServiceClientExample + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\Bin\Debug\Newtonsoft.Json.dll + + + ..\..\Bin\Debug\OpenStack.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/EchoPocoClient.cs b/OpenStack/Examples/CustomServiceClientExample/EchoPocoClient.cs new file mode 100644 index 0000000..a37cc62 --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/EchoPocoClient.cs @@ -0,0 +1,41 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; +using OpenStack.Common.ServiceLocation; + +namespace CustomServiceClientExample +{ + internal class EchoPocoClient : IEchoPocoClient + { + internal IServiceLocator ServiceLocator; + + public EchoPocoClient(IServiceLocator serviceLocator) + { + this.ServiceLocator = serviceLocator; + } + + public async Task Echo(string message) + { + var restClient = this.ServiceLocator.Locate().Create(this.ServiceLocator); + var resp = await restClient.Echo(message); + var payload = await resp.ReadContentAsStringAsync(); + var obj = JObject.Parse(payload); + return new EchoResponse((string)obj["args"]["m"], (string)obj["url"]); + } + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/EchoPocoClientFactory.cs b/OpenStack/Examples/CustomServiceClientExample/EchoPocoClientFactory.cs new file mode 100644 index 0000000..ff4de25 --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/EchoPocoClientFactory.cs @@ -0,0 +1,28 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using OpenStack.Common.ServiceLocation; + +namespace CustomServiceClientExample +{ + internal class EchoPocoClientFactory : IEchoPocoClientFactory + { + public IEchoPocoClient Create(IServiceLocator serviceLocator) + { + return new EchoPocoClient(serviceLocator); + } + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/EchoResponse.cs b/OpenStack/Examples/CustomServiceClientExample/EchoResponse.cs new file mode 100644 index 0000000..abcf48a --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/EchoResponse.cs @@ -0,0 +1,31 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +namespace CustomServiceClientExample +{ + public class EchoResponse + { + public string Message { get; private set; } + + public string Url { get; private set; } + + public EchoResponse(string message, string url) + { + this.Message = message; + this.Url = url; + } + } +} diff --git a/OpenStack/Examples/CustomServiceClientExample/EchoRestClient.cs b/OpenStack/Examples/CustomServiceClientExample/EchoRestClient.cs new file mode 100644 index 0000000..d6ec888 --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/EchoRestClient.cs @@ -0,0 +1,45 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using OpenStack.Common.Http; +using OpenStack.Common.ServiceLocation; + +namespace CustomServiceClientExample +{ + internal class EchoRestClient : IEchoRestClient + { + internal const string serviceEndpoint = "http://httpbin.org/get"; + + internal IServiceLocator ServiceLocator; + + public EchoRestClient(IServiceLocator serviceLocator) + { + this.ServiceLocator = serviceLocator; + } + + public async Task Echo(string message) + { + var client = this.ServiceLocator.Locate().Create(CancellationToken.None); + client.Method = HttpMethod.Get; + client.Uri = new Uri(serviceEndpoint + "?m=" + message); + return await client.SendAsync(); + } + } +} diff --git a/OpenStack/Examples/CustomServiceClientExample/EchoRestClientFactory.cs b/OpenStack/Examples/CustomServiceClientExample/EchoRestClientFactory.cs new file mode 100644 index 0000000..a57cfa2 --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/EchoRestClientFactory.cs @@ -0,0 +1,28 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using OpenStack.Common.ServiceLocation; + +namespace CustomServiceClientExample +{ + internal class EchoRestClientFactory : IEchoRestClientFactory + { + public IEchoRestClient Create(IServiceLocator serviceLocator) + { + return new EchoRestClient(serviceLocator); + } + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/EchoServiceClient.cs b/OpenStack/Examples/CustomServiceClientExample/EchoServiceClient.cs new file mode 100644 index 0000000..3b23c23 --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/EchoServiceClient.cs @@ -0,0 +1,39 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using System.Threading; +using System.Threading.Tasks; +using OpenStack.Common.ServiceLocation; +using OpenStack.Identity; + +namespace CustomServiceClientExample +{ + internal class EchoServiceClient : IEchoServiceClient + { + internal IServiceLocator ServiceLocator; + + public EchoServiceClient(ICredential credential, CancellationToken token, IServiceLocator serviceLocator) + { + this.ServiceLocator = serviceLocator; + } + + public async Task Echo(string message) + { + var pocoClient = this.ServiceLocator.Locate().Create(this.ServiceLocator); + return await pocoClient.Echo(message); + } + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/EchoServiceClientDefinition.cs b/OpenStack/Examples/CustomServiceClientExample/EchoServiceClientDefinition.cs new file mode 100644 index 0000000..3bd64dc --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/EchoServiceClientDefinition.cs @@ -0,0 +1,49 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using System.Collections.Generic; +using System.Threading; +using OpenStack; +using OpenStack.Common.ServiceLocation; +using OpenStack.Identity; + +namespace CustomServiceClientExample +{ + internal class EchoServiceClientDefinition : IOpenStackServiceClientDefinition + { + public string Name { get; private set; } + + public EchoServiceClientDefinition() + { + this.Name = typeof(EchoServiceClient).Name; + } + + public IOpenStackServiceClient Create(ICredential credential, CancellationToken cancellationToken, IServiceLocator serviceLocator) + { + return new EchoServiceClient(credential, cancellationToken, serviceLocator); + } + + public IEnumerable ListSupportedVersions() + { + return new List(); + } + + public bool IsSupported(ICredential credential) + { + return true; + } + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/EchoServiceRegistrar.cs b/OpenStack/Examples/CustomServiceClientExample/EchoServiceRegistrar.cs new file mode 100644 index 0000000..ac7a01c --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/EchoServiceRegistrar.cs @@ -0,0 +1,32 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using OpenStack; +using OpenStack.Common.ServiceLocation; + +namespace CustomServiceClientExample +{ + public class EchoServiceRegistrar : IServiceLocationRegistrar + { + public void Register(IServiceLocationManager manager, IServiceLocator locator) + { + manager.RegisterServiceInstance(typeof(IEchoPocoClientFactory), new EchoPocoClientFactory()); + manager.RegisterServiceInstance(typeof(IEchoRestClientFactory), new EchoRestClientFactory()); + var serviceManager = locator.Locate(); + serviceManager.RegisterServiceClient(new EchoServiceClientDefinition()); + } + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/IEchoPocoClient.cs b/OpenStack/Examples/CustomServiceClientExample/IEchoPocoClient.cs new file mode 100644 index 0000000..a6da5eb --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/IEchoPocoClient.cs @@ -0,0 +1,25 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using System.Threading.Tasks; + +namespace CustomServiceClientExample +{ + public interface IEchoPocoClient + { + Task Echo(string message); + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/IEchoPocoClientFactory.cs b/OpenStack/Examples/CustomServiceClientExample/IEchoPocoClientFactory.cs new file mode 100644 index 0000000..136f1af --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/IEchoPocoClientFactory.cs @@ -0,0 +1,25 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using OpenStack.Common.ServiceLocation; + +namespace CustomServiceClientExample +{ + public interface IEchoPocoClientFactory + { + IEchoPocoClient Create(IServiceLocator serviceLocator); + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/IEchoRestClient.cs b/OpenStack/Examples/CustomServiceClientExample/IEchoRestClient.cs new file mode 100644 index 0000000..ebe69c1 --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/IEchoRestClient.cs @@ -0,0 +1,26 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using System.Threading.Tasks; +using OpenStack.Common.Http; + +namespace CustomServiceClientExample +{ + public interface IEchoRestClient + { + Task Echo(string message); + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/IEchoRestClientFactory.cs b/OpenStack/Examples/CustomServiceClientExample/IEchoRestClientFactory.cs new file mode 100644 index 0000000..1d83b22 --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/IEchoRestClientFactory.cs @@ -0,0 +1,25 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using OpenStack.Common.ServiceLocation; + +namespace CustomServiceClientExample +{ + public interface IEchoRestClientFactory + { + IEchoRestClient Create(IServiceLocator serviceLocator); + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/IEchoServiceClient.cs b/OpenStack/Examples/CustomServiceClientExample/IEchoServiceClient.cs new file mode 100644 index 0000000..2c9f003 --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/IEchoServiceClient.cs @@ -0,0 +1,26 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using System.Threading.Tasks; +using OpenStack; + +namespace CustomServiceClientExample +{ + public interface IEchoServiceClient : IOpenStackServiceClient + { + Task Echo(string message); + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/Program.cs b/OpenStack/Examples/CustomServiceClientExample/Program.cs new file mode 100644 index 0000000..7a3a0e2 --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/Program.cs @@ -0,0 +1,55 @@ +// /* ============================================================================ +// Copyright 2014 Hewlett Packard +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ */ + +using System; +using System.Threading.Tasks; +using OpenStack; +using OpenStack.Identity; + +namespace CustomServiceClientExample +{ + class Program + { + static void Main(string[] args) + { + var authUri = new Uri("https://region.identity.host.com:12345/v2.0/tokens"); + var userName = "user name"; + var password = "password"; + var tenantId = "XXXXXXXXXXXXXX-Project"; + var echoMessage = "Hello world!"; + + Console.WriteLine("Calling remote service to echo the following message: '{0}'", echoMessage); + + var echoMessageTask = EchoMessage(echoMessage, authUri, userName, password, tenantId); + echoMessageTask.Wait(); + + Console.WriteLine("Response from remote service: '{0}'", echoMessageTask.Result); + Console.ReadLine(); + } + + public static async Task EchoMessage(string message, Uri authUri, string userName, string password, string tenantId) + { + var credential = new OpenStackCredential(authUri, userName, password, tenantId); + var client = OpenStackClientFactory.CreateClient(credential); + + await client.Connect(); + + var echoServiceClient = client.CreateServiceClient(); + var resp = await echoServiceClient.Echo(message); + return resp.Message; + } + } +} \ No newline at end of file diff --git a/OpenStack/Examples/CustomServiceClientExample/Properties/AssemblyInfo.cs b/OpenStack/Examples/CustomServiceClientExample/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..cba98de --- /dev/null +++ b/OpenStack/Examples/CustomServiceClientExample/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CustomServiceClientExample")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("CustomServiceClientExample")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4cc5544b-fdb5-43ef-8108-9ed8e995d114")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenStack/Examples/Examples.sln b/OpenStack/Examples/Examples.sln index 45ea187..0f4cf55 100644 --- a/OpenStack/Examples/Examples.sln +++ b/OpenStack/Examples/Examples.sln @@ -1,10 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +VisualStudioVersion = 12.0.30110.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleStorageExample", "SimpleStorageExample\SimpleStorageExample.csproj", "{A8BB096A-9E6F-4D84-B091-F1FCF4DDCBDC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomServiceClientExample", "CustomServiceClientExample\CustomServiceClientExample.csproj", "{83B16A76-A3DF-42E5-95A6-5BBE41FC7854}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {A8BB096A-9E6F-4D84-B091-F1FCF4DDCBDC}.Debug|Any CPU.Build.0 = Debug|Any CPU {A8BB096A-9E6F-4D84-B091-F1FCF4DDCBDC}.Release|Any CPU.ActiveCfg = Release|Any CPU {A8BB096A-9E6F-4D84-B091-F1FCF4DDCBDC}.Release|Any CPU.Build.0 = Release|Any CPU + {83B16A76-A3DF-42E5-95A6-5BBE41FC7854}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83B16A76-A3DF-42E5-95A6-5BBE41FC7854}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83B16A76-A3DF-42E5-95A6-5BBE41FC7854}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83B16A76-A3DF-42E5-95A6-5BBE41FC7854}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE