Skip to content
This repository was archived by the owner on Feb 12, 2019. It is now read-only.

Extended Builds API, Change entity and improved File entity #94

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/TeamCitySharp/ActionTypes/Builds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ public List<Build> ByBuildLocator(BuildLocator locator)
return new List<Build>();
}

public Build ByBuildApi(BuildTypeLocator locator)
{
var buildWrapper = _caller.GetFormat<Build>("/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(
Expand Down
1 change: 1 addition & 0 deletions src/TeamCitySharp/ActionTypes/IBuilds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ public interface IBuilds
List<Build> ByBranch(string branchName);
Build LastBuildByAgent(string agentName);
void Add2QueueBuildByBuildConfigId(string buildConfigId);
Build ByBuildId(string id);
}
}
1 change: 1 addition & 0 deletions src/TeamCitySharp/ActionTypes/IProjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace TeamCitySharp.ActionTypes
public interface IProjects
{
List<Project> All();
List<DomainEntities.CCTray.Project> CruiseControlTray();
Project ByName(string projectLocatorName);
Project ById(string projectLocatorId);
Project Details(Project project);
Expand Down
114 changes: 60 additions & 54 deletions src/TeamCitySharp/ActionTypes/Projects.cs
Original file line number Diff line number Diff line change
@@ -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<Project> All()
{
namespace TeamCitySharp.ActionTypes
{
internal class Projects : IProjects
{
private readonly TeamCityCaller _caller;

internal Projects(TeamCityCaller caller)
{
_caller = caller;
}

public List<Project> All()
{
var projectWrapper = _caller.Get<ProjectWrapper>("/app/rest/projects");
return projectWrapper.Project;

return projectWrapper.Project;
}

public Project ByName(string projectLocatorName)
public List<DomainEntities.CCTray.Project> CruiseControlTray()
{
var project = _caller.GetFormat<Project>("/app/rest/projects/name:{0}", projectLocatorName);

return project;
}

public Project ById(string projectLocatorId)
{
var project = _caller.GetFormat<Project>("/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<Project>(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<DomainEntities.CCTray.ProjectWrapper>("/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<Project>("/app/rest/projects/name:{0}", projectLocatorName);

return project;
}

public Project ById(string projectLocatorId)
{
var project = _caller.GetFormat<Project>("/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<Project>(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);
}
}
}
4 changes: 3 additions & 1 deletion src/TeamCitySharp/DomainEntities/Change.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using JsonFx.Json;

namespace TeamCitySharp.DomainEntities
{
Expand All @@ -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; }
}
Expand Down
19 changes: 19 additions & 0 deletions src/TeamCitySharp/DomainEntities/CruiseControlTray/Project.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace TeamCitySharp.DomainEntities.CCTray
{
public class ProjectWrapper
{
public List<Project> Project { get; set; }
}
}
13 changes: 11 additions & 2 deletions src/TeamCitySharp/DomainEntities/File.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
13 changes: 8 additions & 5 deletions src/TeamCitySharp/TeamCitySharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -67,6 +68,8 @@
<Compile Include="ActionTypes\Projects.cs" />
<Compile Include="ActionTypes\ServerInformation.cs" />
<Compile Include="Connection\ITeamCityCaller.cs" />
<Compile Include="DomainEntities\CruiseControlTray\Project.cs" />
<Compile Include="DomainEntities\CruiseControlTray\ProjectWrapper.cs" />
<Compile Include="TeamCityClient.cs" />
<Compile Include="ActionTypes\Users.cs" />
<Compile Include="ActionTypes\VcsRoots.cs" />
Expand Down Expand Up @@ -125,10 +128,10 @@
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

<Target Name="AfterBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="AfterBuild">
</Target>
-->
</Project>