diff --git a/src/TeamCitySharp/ActionTypes/Builds.cs b/src/TeamCitySharp/ActionTypes/Builds.cs index 4c52f340..630f2ef6 100644 --- a/src/TeamCitySharp/ActionTypes/Builds.cs +++ b/src/TeamCitySharp/ActionTypes/Builds.cs @@ -26,6 +26,21 @@ public List ByBuildLocator(BuildLocator locator) return new List(); } + public Build ByBuildApi(BuildTypeLocator locator) + { + var buildWrapper = _caller.GetFormat("/app/rest/builds/{0}", locator); + if (buildWrapper != null) + { + return buildWrapper; + } + return new Build(); + } + + public Build ByBuildId(string id) + { + return ByBuildApi(BuildTypeLocator.WithId(id)); + } + public Build LastBuildByAgent(string agentName) { return ByBuildLocator(BuildLocator.WithDimensions( diff --git a/src/TeamCitySharp/ActionTypes/IBuilds.cs b/src/TeamCitySharp/ActionTypes/IBuilds.cs index 6afba988..193adfb0 100644 --- a/src/TeamCitySharp/ActionTypes/IBuilds.cs +++ b/src/TeamCitySharp/ActionTypes/IBuilds.cs @@ -24,5 +24,6 @@ public interface IBuilds List ByBranch(string branchName); Build LastBuildByAgent(string agentName); void Add2QueueBuildByBuildConfigId(string buildConfigId); + Build ByBuildId(string id); } } \ No newline at end of file diff --git a/src/TeamCitySharp/ActionTypes/IProjects.cs b/src/TeamCitySharp/ActionTypes/IProjects.cs index febce5c2..c6af1ba2 100644 --- a/src/TeamCitySharp/ActionTypes/IProjects.cs +++ b/src/TeamCitySharp/ActionTypes/IProjects.cs @@ -6,6 +6,7 @@ namespace TeamCitySharp.ActionTypes public interface IProjects { List All(); + List CruiseControlTray(); Project ByName(string projectLocatorName); Project ById(string projectLocatorId); Project Details(Project project); diff --git a/src/TeamCitySharp/ActionTypes/Projects.cs b/src/TeamCitySharp/ActionTypes/Projects.cs index d19ec642..f86d3db3 100644 --- a/src/TeamCitySharp/ActionTypes/Projects.cs +++ b/src/TeamCitySharp/ActionTypes/Projects.cs @@ -1,63 +1,69 @@ -using System.Collections.Generic; -using EasyHttp.Http; -using TeamCitySharp.Connection; +using System.Collections.Generic; +using EasyHttp.Http; +using TeamCitySharp.Connection; using TeamCitySharp.DomainEntities; -namespace TeamCitySharp.ActionTypes -{ - internal class Projects : IProjects - { - private readonly TeamCityCaller _caller; - - internal Projects(TeamCityCaller caller) - { - _caller = caller; - } - - public List All() - { +namespace TeamCitySharp.ActionTypes +{ + internal class Projects : IProjects + { + private readonly TeamCityCaller _caller; + + internal Projects(TeamCityCaller caller) + { + _caller = caller; + } + + public List All() + { var projectWrapper = _caller.Get("/app/rest/projects"); - - return projectWrapper.Project; + + return projectWrapper.Project; } - public Project ByName(string projectLocatorName) + public List CruiseControlTray() { - var project = _caller.GetFormat("/app/rest/projects/name:{0}", projectLocatorName); - - return project; - } - - public Project ById(string projectLocatorId) - { - var project = _caller.GetFormat("/app/rest/projects/id:{0}", projectLocatorId); - - return project; - } - - public Project Details(Project project) - { - return ById(project.Id); - } - - public Project Create(string projectName) - { - return _caller.Post(projectName, HttpContentTypes.TextPlain, "/app/rest/projects/", HttpContentTypes.ApplicationJson); - } - - public void Delete(string projectName) - { - _caller.DeleteFormat("/app/rest/projects/name:{0}", projectName); - } - - public void DeleteProjectParameter(string projectName, string parameterName) - { - _caller.DeleteFormat("/app/rest/projects/name:{0}/parameters/{1}", projectName, parameterName); + var projectWrapper = _caller.Get("/app/rest/cctray"); + return projectWrapper.Project; } - public void SetProjectParameter(string projectName, string settingName, string settingValue) - { - _caller.PutFormat(settingValue, "/app/rest/projects/name:{0}/parameters/{1}", projectName, settingName); - } - } + public Project ByName(string projectLocatorName) + { + var project = _caller.GetFormat("/app/rest/projects/name:{0}", projectLocatorName); + + return project; + } + + public Project ById(string projectLocatorId) + { + var project = _caller.GetFormat("/app/rest/projects/id:{0}", projectLocatorId); + + return project; + } + + public Project Details(Project project) + { + return ById(project.Id); + } + + public Project Create(string projectName) + { + return _caller.Post(projectName, HttpContentTypes.TextPlain, "/app/rest/projects/", HttpContentTypes.ApplicationJson); + } + + public void Delete(string projectName) + { + _caller.DeleteFormat("/app/rest/projects/name:{0}", projectName); + } + + public void DeleteProjectParameter(string projectName, string parameterName) + { + _caller.DeleteFormat("/app/rest/projects/name:{0}/parameters/{1}", projectName, parameterName); + } + + public void SetProjectParameter(string projectName, string settingName, string settingValue) + { + _caller.PutFormat(settingValue, "/app/rest/projects/name:{0}/parameters/{1}", projectName, settingName); + } + } } \ No newline at end of file diff --git a/src/TeamCitySharp/DomainEntities/Change.cs b/src/TeamCitySharp/DomainEntities/Change.cs index d414cf42..3a67576f 100644 --- a/src/TeamCitySharp/DomainEntities/Change.cs +++ b/src/TeamCitySharp/DomainEntities/Change.cs @@ -1,4 +1,5 @@ using System; +using JsonFx.Json; namespace TeamCitySharp.DomainEntities { @@ -10,7 +11,8 @@ public class Change public string Id { get; set; } public string Version { get; set; } public DateTime Date { get; set; } - public string Comment { get; set; } + public string Comment { get; set; } + public User User { get; set; } public FileWrapper Files { get; set; } } diff --git a/src/TeamCitySharp/DomainEntities/CruiseControlTray/Project.cs b/src/TeamCitySharp/DomainEntities/CruiseControlTray/Project.cs new file mode 100644 index 00000000..e6c71e85 --- /dev/null +++ b/src/TeamCitySharp/DomainEntities/CruiseControlTray/Project.cs @@ -0,0 +1,19 @@ +using System; + +namespace TeamCitySharp.DomainEntities.CCTray +{ + public class Project + { + public string Activity { get; set; } + public int LastBuildLabel { get; set; } + public string LastBuildStatus { get; set; } + public DateTime LastBuildTime { get; set; } + public string Name { get; set; } + public string WebUrl { get; set; } + + public override string ToString() + { + return Name; + } + } +} \ No newline at end of file diff --git a/src/TeamCitySharp/DomainEntities/CruiseControlTray/ProjectWrapper.cs b/src/TeamCitySharp/DomainEntities/CruiseControlTray/ProjectWrapper.cs new file mode 100644 index 00000000..cdd6b386 --- /dev/null +++ b/src/TeamCitySharp/DomainEntities/CruiseControlTray/ProjectWrapper.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace TeamCitySharp.DomainEntities.CCTray +{ + public class ProjectWrapper + { + public List Project { get; set; } + } +} \ No newline at end of file diff --git a/src/TeamCitySharp/DomainEntities/File.cs b/src/TeamCitySharp/DomainEntities/File.cs index 11a3b972..6dd950b7 100644 --- a/src/TeamCitySharp/DomainEntities/File.cs +++ b/src/TeamCitySharp/DomainEntities/File.cs @@ -1,7 +1,16 @@ -namespace TeamCitySharp.DomainEntities +using JsonFx.Json; + +namespace TeamCitySharp.DomainEntities { public class File { - public string relativefile { get; set; } + [JsonName("relative-file")] + public string RelativeFile { get; set; } + [JsonName("before-revision")] + public string BeforeRevision { get; set; } + [JsonName("after-revision")] + public string AfterRevision { get; set; } + [JsonName("file")] + public string BaseFile { get; set; } } } \ No newline at end of file diff --git a/src/TeamCitySharp/TeamCitySharp.csproj b/src/TeamCitySharp/TeamCitySharp.csproj index 2e7df5aa..3ed87006 100644 --- a/src/TeamCitySharp/TeamCitySharp.csproj +++ b/src/TeamCitySharp/TeamCitySharp.csproj @@ -42,6 +42,7 @@ + @@ -67,6 +68,8 @@ + + @@ -125,10 +128,10 @@ - \ No newline at end of file