From b2cc604ba660cf674418d7c1426bdbf1e99fcdb8 Mon Sep 17 00:00:00 2001 From: Friedrich Brunzema Date: Sat, 11 Mar 2017 23:23:40 -0500 Subject: [PATCH 1/3] Fixed CR/LF issue opening the project --- src/TeamCitySharp/DomainEntities/Server.cs | 18 +++++++++--------- src/TeamCitySharp/ITeamCityClient.cs | 6 +++--- src/TeamCitySharp/Locators/BuildLocator.cs | 2 +- src/TeamCitySharp/TeamCityClient.cs | 16 ++++++++-------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/TeamCitySharp/DomainEntities/Server.cs b/src/TeamCitySharp/DomainEntities/Server.cs index 6124ad67..df88fbf2 100644 --- a/src/TeamCitySharp/DomainEntities/Server.cs +++ b/src/TeamCitySharp/DomainEntities/Server.cs @@ -1,13 +1,13 @@ using System; -namespace TeamCitySharp.DomainEntities -{ - public class Server - { - public string VersonMajor { get; set; } - public string Version { get; set; } - public string BuildNumber { get; set; } +namespace TeamCitySharp.DomainEntities +{ + public class Server + { + public string VersonMajor { get; set; } + public string Version { get; set; } + public string BuildNumber { get; set; } public DateTime CurrentTime { get; set; } - public DateTime StartTime { get; set; } - } + public DateTime StartTime { get; set; } + } } \ No newline at end of file diff --git a/src/TeamCitySharp/ITeamCityClient.cs b/src/TeamCitySharp/ITeamCityClient.cs index f63f97d3..f8c6f3c8 100644 --- a/src/TeamCitySharp/ITeamCityClient.cs +++ b/src/TeamCitySharp/ITeamCityClient.cs @@ -1,4 +1,4 @@ -using TeamCitySharp.ActionTypes; +using TeamCitySharp.ActionTypes; namespace TeamCitySharp { @@ -7,7 +7,7 @@ public interface ITeamCityClient void Connect(string userName, string password); void ConnectAsGuest(); bool Authenticate(); - + IBuilds Builds { get; } IBuildConfigs BuildConfigs { get; } IProjects Projects { get; } @@ -16,6 +16,6 @@ public interface ITeamCityClient IAgents Agents { get; } IVcsRoots VcsRoots { get; } IChanges Changes { get; } - IBuildArtifacts Artifacts { get; } + IBuildArtifacts Artifacts { get; } } } \ No newline at end of file diff --git a/src/TeamCitySharp/Locators/BuildLocator.cs b/src/TeamCitySharp/Locators/BuildLocator.cs index 1823d6d7..e8ab9777 100644 --- a/src/TeamCitySharp/Locators/BuildLocator.cs +++ b/src/TeamCitySharp/Locators/BuildLocator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace TeamCitySharp.Locators diff --git a/src/TeamCitySharp/TeamCityClient.cs b/src/TeamCitySharp/TeamCityClient.cs index eeb9bb82..a3520274 100644 --- a/src/TeamCitySharp/TeamCityClient.cs +++ b/src/TeamCitySharp/TeamCityClient.cs @@ -1,4 +1,4 @@ -using TeamCitySharp.ActionTypes; +using TeamCitySharp.ActionTypes; using TeamCitySharp.Connection; namespace TeamCitySharp @@ -37,8 +37,8 @@ public bool Authenticate() } public IBuilds Builds - { - get { return _builds ?? (_builds = new Builds(_caller)); } + { + get { return _builds ?? (_builds = new Builds(_caller)); } } public IBuildConfigs BuildConfigs @@ -55,8 +55,8 @@ public IServerInformation ServerInformation { get { return _serverInformation ?? (_serverInformation = new ServerInformation(_caller)); } } - - public IUsers Users + + public IUsers Users { get { return _users ?? (_users = new Users(_caller)); } } @@ -72,8 +72,8 @@ public IVcsRoots VcsRoots } public IChanges Changes - { - get { return _changes ?? (_changes = new Changes(_caller)); } + { + get { return _changes ?? (_changes = new Changes(_caller)); } } public IBuildArtifacts Artifacts @@ -81,4 +81,4 @@ public IBuildArtifacts Artifacts get { return _artifacts ?? (_artifacts = new BuildArtifacts(_caller)); } } } -} +} From ea33fb3e0805464668f6747e0d902824d92a0bae Mon Sep 17 00:00:00 2001 From: Friedrich Brunzema Date: Sun, 12 Mar 2017 01:04:49 -0500 Subject: [PATCH 2/3] Added basic AgentPool functionality --- src/TeamCitySharp/ActionTypes/AgentPools.cs | 36 +++++++++++++ src/TeamCitySharp/ActionTypes/IAgentPools.cs | 14 +++++ src/TeamCitySharp/DomainEntities/AgentPool.cs | 15 ++++++ .../DomainEntities/AgentPoolWrapper.cs | 9 ++++ src/TeamCitySharp/ITeamCityClient.cs | 1 + src/TeamCitySharp/TeamCityClient.cs | 5 ++ src/TeamCitySharp/TeamCitySharp.csproj | 4 ++ .../UnitTests/ActionTypes/AgentPoolTest.cs | 54 +++++++++++++++++++ .../UnitTests/TeamCitySharp.UnitTests.csproj | 1 + 9 files changed, 139 insertions(+) create mode 100644 src/TeamCitySharp/ActionTypes/AgentPools.cs create mode 100644 src/TeamCitySharp/ActionTypes/IAgentPools.cs create mode 100644 src/TeamCitySharp/DomainEntities/AgentPool.cs create mode 100644 src/TeamCitySharp/DomainEntities/AgentPoolWrapper.cs create mode 100644 src/Tests/UnitTests/ActionTypes/AgentPoolTest.cs diff --git a/src/TeamCitySharp/ActionTypes/AgentPools.cs b/src/TeamCitySharp/ActionTypes/AgentPools.cs new file mode 100644 index 00000000..d7fe9507 --- /dev/null +++ b/src/TeamCitySharp/ActionTypes/AgentPools.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; +using TeamCitySharp.Connection; +using TeamCitySharp.DomainEntities; + +namespace TeamCitySharp.ActionTypes +{ + internal class AgentPools : IAgentPools + { + private readonly TeamCityCaller _caller; + + internal AgentPools(TeamCityCaller caller) + { + _caller = caller; + } + + public List All() + { + var agentPoolWrapper = _caller.Get("/app/rest/agentPools"); + + return agentPoolWrapper.AgentPool; + } + + public List AgentsByAgentPoolId(string id) + { + var agentWrapper = _caller.GetFormat("/app/rest/agentPools/id:{0}/agents", id); + + return agentWrapper?.Agent; + } + + public List ProjectsByAgentPoolId(string id) + { + var projectWrapper = _caller.GetFormat("/app/rest/agentPools/id:{0}/projects", id); + return projectWrapper?.Project; + } + } +} \ No newline at end of file diff --git a/src/TeamCitySharp/ActionTypes/IAgentPools.cs b/src/TeamCitySharp/ActionTypes/IAgentPools.cs new file mode 100644 index 00000000..30f25f10 --- /dev/null +++ b/src/TeamCitySharp/ActionTypes/IAgentPools.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using TeamCitySharp.DomainEntities; + +namespace TeamCitySharp.ActionTypes +{ + public interface IAgentPools + { + List All(); + + List AgentsByAgentPoolId(string id); + + List ProjectsByAgentPoolId(string id); + } +} \ No newline at end of file diff --git a/src/TeamCitySharp/DomainEntities/AgentPool.cs b/src/TeamCitySharp/DomainEntities/AgentPool.cs new file mode 100644 index 00000000..beab0fe8 --- /dev/null +++ b/src/TeamCitySharp/DomainEntities/AgentPool.cs @@ -0,0 +1,15 @@ +namespace TeamCitySharp.DomainEntities +{ + public class AgentPool + { + public string Name { get; set; } + public string Id { get; set; } + public string Href { get; set; } + + + public override string ToString() + { + return Name; + } + } +} diff --git a/src/TeamCitySharp/DomainEntities/AgentPoolWrapper.cs b/src/TeamCitySharp/DomainEntities/AgentPoolWrapper.cs new file mode 100644 index 00000000..9cec3d54 --- /dev/null +++ b/src/TeamCitySharp/DomainEntities/AgentPoolWrapper.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace TeamCitySharp.DomainEntities +{ + public class AgentPoolWrapper + { + public List AgentPool { get; set; } + } +} \ No newline at end of file diff --git a/src/TeamCitySharp/ITeamCityClient.cs b/src/TeamCitySharp/ITeamCityClient.cs index f8c6f3c8..c73797e4 100644 --- a/src/TeamCitySharp/ITeamCityClient.cs +++ b/src/TeamCitySharp/ITeamCityClient.cs @@ -14,6 +14,7 @@ public interface ITeamCityClient IServerInformation ServerInformation { get; } IUsers Users { get; } IAgents Agents { get; } + IAgentPools AgentPools { get; } IVcsRoots VcsRoots { get; } IChanges Changes { get; } IBuildArtifacts Artifacts { get; } diff --git a/src/TeamCitySharp/TeamCityClient.cs b/src/TeamCitySharp/TeamCityClient.cs index a3520274..0f826d1b 100644 --- a/src/TeamCitySharp/TeamCityClient.cs +++ b/src/TeamCitySharp/TeamCityClient.cs @@ -12,6 +12,7 @@ public class TeamCityClient : IClientConnection, ITeamCityClient private IServerInformation _serverInformation; private IUsers _users; private IAgents _agents; + private IAgentPools _agentPools; private IVcsRoots _vcsRoots; private IChanges _changes; private IBuildArtifacts _artifacts; @@ -66,6 +67,10 @@ public IAgents Agents get { return _agents ?? (_agents = new Agents(_caller)); } } + public IAgentPools AgentPools + { + get { return _agentPools ?? (_agentPools = new AgentPools(_caller)); } + } public IVcsRoots VcsRoots { get { return _vcsRoots ?? (_vcsRoots = new VcsRoots(_caller)); } diff --git a/src/TeamCitySharp/TeamCitySharp.csproj b/src/TeamCitySharp/TeamCitySharp.csproj index 8834b142..d1fd840c 100644 --- a/src/TeamCitySharp/TeamCitySharp.csproj +++ b/src/TeamCitySharp/TeamCitySharp.csproj @@ -52,12 +52,14 @@ + + @@ -70,6 +72,8 @@ + + diff --git a/src/Tests/UnitTests/ActionTypes/AgentPoolTest.cs b/src/Tests/UnitTests/ActionTypes/AgentPoolTest.cs new file mode 100644 index 00000000..94a16b1e --- /dev/null +++ b/src/Tests/UnitTests/ActionTypes/AgentPoolTest.cs @@ -0,0 +1,54 @@ + + +using System.Diagnostics; +using NUnit.Framework; + +namespace TeamCitySharp.ActionTypes +{ + [TestFixture] + public class AgentPoolTest + { + private TeamCityClient _client; + + [SetUp] + public void SetUp() + { + _client = new TeamCityClient("amcon-tmcityp1.netadds.net:80"); + _client.Connect("friedrich.brunzema", ""); + } + + [Test] + public void ListPools() + { + + var pools = _client.AgentPools.All(); + foreach (var pool in pools) + { + Debug.WriteLine(pool.Name + " Id:" + pool.Id); + } + Assert.That(pools.Count, Is.GreaterThan(10)); + } + + [Test] + public void AgentsByAgentPoolId() + { + var agents = _client.AgentPools.AgentsByAgentPoolId("23"); + foreach (var agent in agents) + { + Debug.WriteLine(agent.Name + " Id:" + agent.Id); + } + Assert.That(agents.Count, Is.GreaterThan(0)); + } + + [Test] + public void ProjectsByAgentPoolId() + { + var projects = _client.AgentPools.ProjectsByAgentPoolId("23"); + foreach (var project in projects) + { + Debug.WriteLine(project.Name + " Id:" + project.Id + " ParentProj:" + project); + } + Assert.That(projects.Count, Is.GreaterThan(0)); + } + } +} \ No newline at end of file diff --git a/src/Tests/UnitTests/TeamCitySharp.UnitTests.csproj b/src/Tests/UnitTests/TeamCitySharp.UnitTests.csproj index dcb835b3..75ddd672 100644 --- a/src/Tests/UnitTests/TeamCitySharp.UnitTests.csproj +++ b/src/Tests/UnitTests/TeamCitySharp.UnitTests.csproj @@ -55,6 +55,7 @@ + From 246f787fe216bc714d40c9699ca92eee1daed939 Mon Sep 17 00:00:00 2001 From: Friedrich Brunzema Date: Sun, 12 Mar 2017 01:12:10 -0500 Subject: [PATCH 3/3] Added ParentProjectId to project domain entity --- src/TeamCitySharp/DomainEntities/Project.cs | 37 ++++++++++--------- .../UnitTests/ActionTypes/AgentPoolTest.cs | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/TeamCitySharp/DomainEntities/Project.cs b/src/TeamCitySharp/DomainEntities/Project.cs index 02a833c7..f90ca986 100644 --- a/src/TeamCitySharp/DomainEntities/Project.cs +++ b/src/TeamCitySharp/DomainEntities/Project.cs @@ -1,20 +1,21 @@ -namespace TeamCitySharp.DomainEntities -{ - public class Project - { - public override string ToString() - { - return Name; - } - - public bool Archived { get; set; } - public string Description { get; set; } - public string Href { get; set; } - public string Id { get; set; } - public string Name { get; set; } - public string WebUrl { get; set; } - +namespace TeamCitySharp.DomainEntities +{ + public class Project + { + public override string ToString() + { + return Name; + } + + public bool Archived { get; set; } + public string Description { get; set; } + public string Href { get; set; } + public string Id { get; set; } + public string Name { get; set; } + public string WebUrl { get; set; } + public string ParentProjectId { get; set; } + public BuildTypeWrapper BuildTypes { get; set; } - public Parameters Parameters { get; set; } - } + public Parameters Parameters { get; set; } + } } \ No newline at end of file diff --git a/src/Tests/UnitTests/ActionTypes/AgentPoolTest.cs b/src/Tests/UnitTests/ActionTypes/AgentPoolTest.cs index 94a16b1e..f7dbaab6 100644 --- a/src/Tests/UnitTests/ActionTypes/AgentPoolTest.cs +++ b/src/Tests/UnitTests/ActionTypes/AgentPoolTest.cs @@ -46,7 +46,7 @@ public void ProjectsByAgentPoolId() var projects = _client.AgentPools.ProjectsByAgentPoolId("23"); foreach (var project in projects) { - Debug.WriteLine(project.Name + " Id:" + project.Id + " ParentProj:" + project); + Debug.WriteLine(project.Name + " Id:" + project.Id + " ParentProjId:" + project.ParentProjectId); } Assert.That(projects.Count, Is.GreaterThan(0)); }