diff --git a/src/TeamCitySharp/ActionTypes/BuildDetails.cs b/src/TeamCitySharp/ActionTypes/BuildDetails.cs new file mode 100644 index 00000000..fb7d8bcb --- /dev/null +++ b/src/TeamCitySharp/ActionTypes/BuildDetails.cs @@ -0,0 +1,25 @@ +using System.Linq; +using System.Collections.Generic; +using TeamCitySharp.Connection; +using TeamCitySharp.DomainEntities; +using TeamCitySharp.Locators; + +namespace TeamCitySharp.ActionTypes +{ + internal class BuildDetails : IBuildDetails + { + private readonly TeamCityCaller _caller; + + internal BuildDetails(TeamCityCaller caller) + { + _caller = caller; + } + + public Build ByBuildLocator(BuildLocator locator) + { + var buildWrapper = _caller.GetFormat("/app/rest/builds/{0}", locator); + + return buildWrapper.Build == null ? null : buildWrapper.Build.FirstOrDefault(); + } + } +} \ No newline at end of file diff --git a/src/TeamCitySharp/ActionTypes/Changes.cs b/src/TeamCitySharp/ActionTypes/Changes.cs index 5218b4aa..8e088c4d 100644 --- a/src/TeamCitySharp/ActionTypes/Changes.cs +++ b/src/TeamCitySharp/ActionTypes/Changes.cs @@ -2,6 +2,7 @@ using System.Linq; using TeamCitySharp.Connection; using TeamCitySharp.DomainEntities; +using TeamCitySharp.Locators; namespace TeamCitySharp.ActionTypes { @@ -42,5 +43,18 @@ public Change LastChangeDetailByBuildConfigId(string buildConfigId) return changes.FirstOrDefault(); } + public List ByBuildLocator(BuildLocator buildLocator) + { + var changeWrapper = _caller.GetFormat("/app/rest/changes?build={0}", buildLocator); + + if (changeWrapper.Change == null) + { + return new List(); + } + + return changeWrapper.Change + .Select(c => _caller.GetFormat("/app/rest/changes/id:{0}", c.Id)) + .ToList(); + } } } \ No newline at end of file diff --git a/src/TeamCitySharp/ActionTypes/IBuildDetails.cs b/src/TeamCitySharp/ActionTypes/IBuildDetails.cs new file mode 100644 index 00000000..a5157aeb --- /dev/null +++ b/src/TeamCitySharp/ActionTypes/IBuildDetails.cs @@ -0,0 +1,12 @@ +using System.Linq; +using System.Collections.Generic; +using TeamCitySharp.DomainEntities; +using TeamCitySharp.Locators; + +namespace TeamCitySharp.ActionTypes +{ + public interface IBuildDetails + { + Build ByBuildLocator(BuildLocator locator); + } +} \ No newline at end of file diff --git a/src/TeamCitySharp/ActionTypes/IChanges.cs b/src/TeamCitySharp/ActionTypes/IChanges.cs index 1ae51cd5..abee7252 100644 --- a/src/TeamCitySharp/ActionTypes/IChanges.cs +++ b/src/TeamCitySharp/ActionTypes/IChanges.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using TeamCitySharp.DomainEntities; +using TeamCitySharp.Locators; namespace TeamCitySharp.ActionTypes { @@ -9,5 +10,6 @@ public interface IChanges Change ByChangeId(string id); Change LastChangeDetailByBuildConfigId(string buildConfigId); List ByBuildConfigId(string buildConfigId); + List ByBuildLocator(BuildLocator buildLocator); } } \ No newline at end of file diff --git a/src/TeamCitySharp/DomainEntities/Build.cs b/src/TeamCitySharp/DomainEntities/Build.cs index 7d16fc34..944f4a44 100644 --- a/src/TeamCitySharp/DomainEntities/Build.cs +++ b/src/TeamCitySharp/DomainEntities/Build.cs @@ -22,6 +22,5 @@ public override string ToString() { return Number; } - } } \ No newline at end of file diff --git a/src/TeamCitySharp/ITeamCityClient.cs b/src/TeamCitySharp/ITeamCityClient.cs index 0ff3085b..513ff452 100644 --- a/src/TeamCitySharp/ITeamCityClient.cs +++ b/src/TeamCitySharp/ITeamCityClient.cs @@ -8,6 +8,7 @@ public interface ITeamCityClient bool Authenticate(); IBuilds Builds { get; } + IBuildDetails BuildDetails { get; } IBuildConfigs BuildConfigs { get; } IProjects Projects { get; } IServerInformation ServerInformation { get; } diff --git a/src/TeamCitySharp/TeamCityClient.cs b/src/TeamCitySharp/TeamCityClient.cs index 91840e5f..1ec8ac5e 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 @@ -7,6 +7,7 @@ public class TeamCityClient : IClientConnection, ITeamCityClient { private readonly TeamCityCaller _caller; private IBuilds _builds; + private IBuildDetails _buildDetails; private IProjects _projects; private IBuildConfigs _buildConfigs; private IServerInformation _serverInformation; @@ -32,8 +33,13 @@ public bool Authenticate() } public IBuilds Builds - { - get { return _builds ?? (_builds = new Builds(_caller)); } + { + get { return _builds ?? (_builds = new Builds(_caller)); } + } + + public IBuildDetails BuildDetails + { + get { return _buildDetails ?? (_buildDetails = new BuildDetails(_caller)); } } public IBuildConfigs BuildConfigs @@ -50,8 +56,8 @@ public IServerInformation ServerInformation { get { return _serverInformation ?? (_serverInformation = new ServerInformation(_caller)); } } - - public IUsers Users + + public IUsers Users { get { return _users ?? (_users = new Users(_caller)); } } @@ -67,8 +73,8 @@ public IVcsRoots VcsRoots } public IChanges Changes - { - get { return _changes ?? (_changes = new Changes(_caller)); } + { + get { return _changes ?? (_changes = new Changes(_caller)); } } public IBuildArtifacts Artifacts @@ -76,4 +82,4 @@ public IBuildArtifacts Artifacts get { return _artifacts ?? (_artifacts = new BuildArtifacts(_caller)); } } } -} +} diff --git a/src/TeamCitySharp/TeamCitySharp.csproj b/src/TeamCitySharp/TeamCitySharp.csproj index 33a0231e..b91dac6b 100644 --- a/src/TeamCitySharp/TeamCitySharp.csproj +++ b/src/TeamCitySharp/TeamCitySharp.csproj @@ -52,11 +52,13 @@ + +