Skip to content

Commit ecf2a33

Browse files
committed
Add typed client
1 parent 94bce5e commit ecf2a33

File tree

11 files changed

+321
-74
lines changed

11 files changed

+321
-74
lines changed

IntegrationEngine.Client/Client.cs

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using IntegrationEngine.Model;
5+
using RestSharp;
6+
7+
namespace IntegrationEngine.Client
8+
{
9+
public class Client
10+
{
11+
public RestClient RestClient { get; set; }
12+
13+
public Client()
14+
: this("http://localhost:9001/api/")
15+
{
16+
}
17+
18+
public Client(string apiUrl)
19+
{
20+
RestClient = new RestClient(apiUrl);
21+
}
22+
23+
#region CronTrigger
24+
public List<ICronTrigger> GetCronTriggers()
25+
{
26+
var request = new RestRequest(EndpointName.CronTrigger, Method.GET);
27+
return RestClient.Execute<List<ICronTrigger>>(request).Data;
28+
}
29+
30+
public CronTrigger GetCronTriggerById(string id)
31+
{
32+
var request = new RestRequest(EndpointName.CronTrigger + "/{id}", Method.GET);
33+
request.AddUrlSegment("id", id);
34+
return RestClient.Execute<CronTrigger>(request).Data;
35+
}
36+
37+
public CronTrigger CreateCronTrigger(CronTrigger cronTrigger)
38+
{
39+
var request = new RestRequest(EndpointName.CronTrigger, Method.POST);
40+
request.AddObject(cronTrigger);
41+
return RestClient.Execute<CronTrigger>(request).Data;
42+
}
43+
44+
public CronTrigger UpdateCronTrigger(CronTrigger cronTrigger)
45+
{
46+
var request = new RestRequest(EndpointName.CronTrigger + "/{id}", Method.PUT);
47+
request.AddUrlSegment("id", cronTrigger.Id);
48+
request.AddObject(cronTrigger);
49+
return RestClient.Execute<CronTrigger>(request).Data;
50+
}
51+
52+
public CronTrigger DeleteCronTrigger(string id)
53+
{
54+
var request = new RestRequest(EndpointName.CronTrigger + "/{id}", Method.DELETE);
55+
request.AddUrlSegment("id", id);
56+
return RestClient.Execute<CronTrigger>(request).Data;
57+
}
58+
#endregion
59+
60+
#region SimpleTrigger
61+
public List<SimpleTrigger> GetSimpleTriggers()
62+
{
63+
var request = new RestRequest(EndpointName.SimpleTrigger, Method.GET);
64+
return RestClient.Execute<List<SimpleTrigger>>(request).Data;
65+
}
66+
67+
public SimpleTrigger GetSimpleTriggerById(string id)
68+
{
69+
var request = new RestRequest(EndpointName.SimpleTrigger + "/{id}", Method.GET);
70+
request.AddUrlSegment("id", id);
71+
return RestClient.Execute<SimpleTrigger>(request).Data;
72+
}
73+
74+
public SimpleTrigger CreateSimpleTrigger(SimpleTrigger simpleTrigger)
75+
{
76+
var request = new RestRequest(EndpointName.SimpleTrigger, Method.POST);
77+
request.AddObject(simpleTrigger);
78+
return RestClient.Execute<SimpleTrigger>(request).Data;
79+
}
80+
81+
public SimpleTrigger UpdateSimpleTrigger(SimpleTrigger simpleTrigger)
82+
{
83+
var request = new RestRequest(EndpointName.SimpleTrigger + "/{id}", Method.PUT);
84+
request.AddUrlSegment("id", simpleTrigger.Id);
85+
request.AddObject(simpleTrigger);
86+
return RestClient.Execute<SimpleTrigger>(request).Data;
87+
}
88+
89+
public SimpleTrigger DeleteSimpleTrigger(string id)
90+
{
91+
var request = new RestRequest(EndpointName.SimpleTrigger + "/{id}", Method.DELETE);
92+
request.AddUrlSegment("id", id);
93+
return RestClient.Execute<SimpleTrigger>(request).Data;
94+
}
95+
#endregion
96+
97+
#region TimeZone
98+
public List<TimeZone> GetTimeZones()
99+
{
100+
var request = new RestRequest(EndpointName.TimeZone, Method.GET);
101+
return RestClient.Execute<List<TimeZone>>(request).Data;
102+
}
103+
#endregion
104+
105+
#region JobType
106+
public List<string> GetJobTypes()
107+
{
108+
var request = new RestRequest(EndpointName.JobType, Method.GET);
109+
return RestClient.Execute<List<string>>(request).Data;
110+
}
111+
#endregion
112+
}
113+
}
114+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
3+
namespace IntegrationEngine.Client
4+
{
5+
public class EndpointName
6+
{
7+
public static string CronTrigger = "CronTrigger";
8+
public static string SimpleTrigger = "SimpleTrigger";
9+
public static string JobType = "JobType";
10+
public static string TimeZone = "TimeZone";
11+
}
12+
}
13+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{F3FCB706-F0DD-46C1-B121-785757FAE9B9}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<RootNamespace>IntegrationEngine.Client</RootNamespace>
9+
<AssemblyName>IntegrationEngine.Client</AssemblyName>
10+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
13+
<DebugSymbols>true</DebugSymbols>
14+
<DebugType>full</DebugType>
15+
<Optimize>false</Optimize>
16+
<OutputPath>bin\Debug</OutputPath>
17+
<DefineConstants>DEBUG;</DefineConstants>
18+
<ErrorReport>prompt</ErrorReport>
19+
<WarningLevel>4</WarningLevel>
20+
<ConsolePause>false</ConsolePause>
21+
</PropertyGroup>
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
23+
<DebugType>full</DebugType>
24+
<Optimize>true</Optimize>
25+
<OutputPath>bin\Release</OutputPath>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
<ConsolePause>false</ConsolePause>
29+
</PropertyGroup>
30+
<ItemGroup>
31+
<Reference Include="System" />
32+
<Reference Include="RestSharp">
33+
<HintPath>..\packages\RestSharp.105.0.1\lib\net4\RestSharp.dll</HintPath>
34+
</Reference>
35+
</ItemGroup>
36+
<ItemGroup>
37+
<Compile Include="Properties\AssemblyInfo.cs" />
38+
<Compile Include="Client.cs" />
39+
<Compile Include="EndpointName.cs" />
40+
</ItemGroup>
41+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
42+
<ItemGroup>
43+
<ProjectReference Include="..\IntegrationEngine.Model\IntegrationEngine.Model.csproj">
44+
<Project>{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}</Project>
45+
<Name>IntegrationEngine.Model</Name>
46+
</ProjectReference>
47+
</ItemGroup>
48+
<ItemGroup>
49+
<None Include="packages.config" />
50+
<None Include="package.nuspec">
51+
<SubType>Designer</SubType>
52+
</None>
53+
</ItemGroup>
54+
</Project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
// Information about this assembly is defined by the following attributes.
5+
// Change them to the values specific to your project.
6+
7+
[assembly: AssemblyTitle("IntegrationEngine.Client")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("")]
12+
[assembly: AssemblyCopyright("ethanhann")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
16+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
18+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
19+
20+
[assembly: AssemblyVersion("1.0.*")]
21+
22+
// The following attributes are used to specify the signing key for the assembly,
23+
// if desired. See the Mono documentation for more information about signing.
24+
25+
//[assembly: AssemblyDelaySign(false)]
26+
//[assembly: AssemblyKeyFile("")]
27+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0"?>
2+
<package >
3+
<metadata>
4+
<id>$id$</id>
5+
<version>$version$</version>
6+
<title>InEngine.NET Client</title>
7+
<authors>$author$</authors>
8+
<owners>Ethan Hann</owners>
9+
<licenseUrl>https://github.com/ethanhann/InEngine.NET/blob/master/IntegrationEngine/LICENSE</licenseUrl>
10+
<projectUrl>https://github.com/ethanhann/InEngine.NET</projectUrl>
11+
<releaseNotes>http://inengine.net/change-log.html</releaseNotes>
12+
<requireLicenseAcceptance>true</requireLicenseAcceptance>
13+
<description>Client of IntegrationServer, an asynchronous job scheduling server.</description>
14+
<copyright>Copyright 2015</copyright>
15+
<tags>Integration Scheduling Server RabbitMQ Elasticsearch Quartz.NET</tags>
16+
<references>
17+
<reference file="IntegrationEngine.Client.dll" />
18+
</references>
19+
<dependencies>
20+
<dependency id="IntegrationEngine.Model" version="$version$" />
21+
<dependency id="RestSharp" version="105.0.1" />
22+
</dependencies>
23+
</metadata>
24+
</package>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="RestSharp" version="105.0.1" targetFramework="net45" />
4+
</packages>

IntegrationEngine.ConsoleHost/IntegrationEngine.ConsoleHost.csproj

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,12 @@
5959
<Reference Include="Microsoft.Owin.Host.HttpListener">
6060
<HintPath>..\packages\Microsoft.Owin.Host.HttpListener.3.0.0\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>
6161
</Reference>
62-
<Reference Include="RazorEngine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=9ee697374c7e744a, processorArchitecture=MSIL">
63-
<SpecificVersion>False</SpecificVersion>
64-
<HintPath>..\packages\RazorEngine.3.5.0\lib\net45\RazorEngine.dll</HintPath>
65-
</Reference>
6662
<Reference Include="System" />
6763
<Reference Include="System.ComponentModel.DataAnnotations" />
68-
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
69-
<SpecificVersion>False</SpecificVersion>
64+
<Reference Include="RazorEngine">
65+
<HintPath>..\packages\RazorEngine.3.5.0\lib\net45\RazorEngine.dll</HintPath>
66+
</Reference>
67+
<Reference Include="System.Web.Razor">
7068
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll</HintPath>
7169
</Reference>
7270
</ItemGroup>

IntegrationEngine.Core/IntegrationEngine.Core.csproj

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,9 @@
4747
<Reference Include="Nest">
4848
<HintPath>..\packages\NEST.1.3.1\lib\Nest.dll</HintPath>
4949
</Reference>
50-
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
51-
<SpecificVersion>False</SpecificVersion>
52-
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
53-
</Reference>
5450
<Reference Include="NLog">
5551
<HintPath>..\packages\NLog.3.2.0.0\lib\net45\NLog.dll</HintPath>
5652
</Reference>
57-
<Reference Include="RabbitMQ.Client, Version=3.4.3.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL">
58-
<SpecificVersion>False</SpecificVersion>
59-
<HintPath>..\packages\RabbitMQ.Client.3.4.3\lib\net35\RabbitMQ.Client.dll</HintPath>
60-
</Reference>
6153
<Reference Include="System" />
6254
<Reference Include="System.ComponentModel.DataAnnotations" />
6355
<Reference Include="System.Core" />
@@ -78,6 +70,12 @@
7870
<Reference Include="MySql.Data.Entity.EF6, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d">
7971
<HintPath>..\packages\MySql.Data.Entity.6.9.5\lib\net45\MySql.Data.Entity.EF6.dll</HintPath>
8072
</Reference>
73+
<Reference Include="Newtonsoft.Json">
74+
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
75+
</Reference>
76+
<Reference Include="RabbitMQ.Client">
77+
<HintPath>..\packages\RabbitMQ.Client.3.4.3\lib\net35\RabbitMQ.Client.dll</HintPath>
78+
</Reference>
8179
</ItemGroup>
8280
<ItemGroup>
8381
<Compile Include="..\configuration\SharedAssemblyInfo.cs">

IntegrationEngine.Tests/IntegrationEngine.Tests.csproj

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -39,10 +39,6 @@
3939
<Reference Include="fx.configuration">
4040
<HintPath>..\packages\fx.configuration.0.4.0\lib\net45\fx.configuration.dll</HintPath>
4141
</Reference>
42-
<Reference Include="Microsoft.Practices.Unity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
43-
<SpecificVersion>False</SpecificVersion>
44-
<HintPath>..\packages\Unity.3.5.1404.0\lib\net45\Microsoft.Practices.Unity.dll</HintPath>
45-
</Reference>
4642
<Reference Include="Microsoft.Practices.Unity.Configuration">
4743
<HintPath>..\packages\Unity.3.5.1404.0\lib\net45\Microsoft.Practices.Unity.Configuration.dll</HintPath>
4844
</Reference>
@@ -52,30 +48,29 @@
5248
<Reference Include="Moq">
5349
<HintPath>..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll</HintPath>
5450
</Reference>
55-
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
56-
<SpecificVersion>False</SpecificVersion>
57-
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
58-
</Reference>
59-
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
60-
<SpecificVersion>False</SpecificVersion>
61-
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
62-
</Reference>
6351
<Reference Include="System" />
6452
<Reference Include="System.Core" />
6553
<Reference Include="System.Net.Http" />
66-
<Reference Include="System.Net.Http.Formatting, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67-
<SpecificVersion>False</SpecificVersion>
68-
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll</HintPath>
69-
</Reference>
70-
<Reference Include="System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
71-
<SpecificVersion>False</SpecificVersion>
72-
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll</HintPath>
73-
</Reference>
7454
<Reference Include="System.Xml.Linq" />
7555
<Reference Include="System.Data.DataSetExtensions" />
7656
<Reference Include="Microsoft.CSharp" />
7757
<Reference Include="System.Data" />
7858
<Reference Include="System.Xml" />
59+
<Reference Include="Microsoft.Practices.Unity">
60+
<HintPath>..\packages\Unity.3.5.1404.0\lib\net45\Microsoft.Practices.Unity.dll</HintPath>
61+
</Reference>
62+
<Reference Include="Newtonsoft.Json">
63+
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
64+
</Reference>
65+
<Reference Include="nunit.framework">
66+
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
67+
</Reference>
68+
<Reference Include="System.Net.Http.Formatting">
69+
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll</HintPath>
70+
</Reference>
71+
<Reference Include="System.Web.Http">
72+
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll</HintPath>
73+
</Reference>
7974
</ItemGroup>
8075
<ItemGroup>
8176
<Compile Include="Api\Controllers\CronTriggerControllerTest.cs" />
@@ -96,15 +91,15 @@
9691
</ItemGroup>
9792
<ItemGroup>
9893
<ProjectReference Include="..\IntegrationEngine.Core\IntegrationEngine.Core.csproj">
99-
<Project>{3f3794d7-4078-4d26-954c-7864173edd86}</Project>
94+
<Project>{3F3794D7-4078-4D26-954C-7864173EDD86}</Project>
10095
<Name>IntegrationEngine.Core</Name>
10196
</ProjectReference>
10297
<ProjectReference Include="..\IntegrationEngine.Model\IntegrationEngine.Model.csproj">
103-
<Project>{0b499fe4-0bdb-4080-bcb7-f8d4ce54a4ff}</Project>
98+
<Project>{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}</Project>
10499
<Name>IntegrationEngine.Model</Name>
105100
</ProjectReference>
106101
<ProjectReference Include="..\IntegrationEngine\IntegrationEngine.csproj">
107-
<Project>{7d49353d-a68c-4aca-a6a5-40b1c314c30e}</Project>
102+
<Project>{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}</Project>
108103
<Name>IntegrationEngine</Name>
109104
</ProjectReference>
110105
</ItemGroup>

0 commit comments

Comments
 (0)