Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Included Async method from #38

Open
wants to merge 2 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
283 changes: 237 additions & 46 deletions README.md

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions src/TeamCitySharp/ActionTypes/ActionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace TeamCitySharp.ActionTypes
using System.Text.RegularExpressions;

namespace TeamCitySharp.ActionTypes
{
public class ActionHelper
public static class ActionHelper
{
/// <summary>
/// Create a url with fields
Expand All @@ -20,5 +22,12 @@ public static string CreateFieldUrl(string url, string fields)
}
return url;
}
public static string RemoveRestApiFromURL(string url)
{
var pattern = @"^(/httpAuth/app/rest|/app/rest)";
var substitution = @"";
var regex = new Regex(pattern);
return regex.Replace(url, substitution);
}
}
}
15 changes: 14 additions & 1 deletion src/TeamCitySharp/ActionTypes/Agents.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using TeamCitySharp.Connection;
using TeamCitySharp.DomainEntities;
using System.Threading.Tasks;

namespace TeamCitySharp.ActionTypes
{
Expand All @@ -18,7 +19,7 @@ internal Agents(ITeamCityCaller caller)

public Agents GetFields(string fields)
{
var newInstance = (Agents) MemberwiseClone();
var newInstance = (Agents)MemberwiseClone();
newInstance.m_fields = fields;
return newInstance;
}
Expand All @@ -34,5 +35,17 @@ public List<Agent> All(bool includeDisconnected = true, bool includeUnauthorized

return agentWrapper.Agent;
}

public async Task<List<Agent>> AllAsync(bool includeDisconnected = true, bool includeUnauthorized = true)
{
var url =
string.Format(
ActionHelper.CreateFieldUrl("/agents?includeDisconnected={0}&includeUnauthorized={1}", m_fields),
includeDisconnected.ToString().ToLower(), includeUnauthorized.ToString().ToLower());

var agentWrapper = await m_caller.GetAsync<AgentWrapper>(url);

return agentWrapper.Agent;
}
}
}
2 changes: 1 addition & 1 deletion src/TeamCitySharp/ActionTypes/BackupOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class BackupOptions
{
public string Filename { get; set; }
public string FileName { get; set; }

public bool IncludeDatabase { get; set; }

Expand Down
Loading