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

Commit

Permalink
Add two bulk-operation methods new to 8.0: DeleteAllBuildTypeParamete…
Browse files Browse the repository at this point in the history
…rs, PutAllBuildTypeParameters.

Bulk operations give major speedup in mass update of buildtypes.
  • Loading branch information
hypersw committed Jan 30, 2013
1 parent a3dc097 commit 9f93503
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/TeamCitySharp/ActionTypes/BuildConfigs.cs
@@ -1,4 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Mime;
using System.Xml;
using EasyHttp.Http;
using TeamCitySharp.Connection;
Expand Down Expand Up @@ -112,6 +115,35 @@ public void DeleteConfiguration(BuildTypeLocator locator)
_caller.DeleteFormat("/app/rest/buildTypes/{0}", locator);
}

public void DeleteAllBuildTypeParameters(BuildTypeLocator locator)
{
_caller.DeleteFormat("/app/rest/buildTypes/{0}/parameters", locator);
}

public void PutAllBuildTypeParameters(BuildTypeLocator locator, IDictionary<string, string> parameters)
{
if(locator == null)
throw new ArgumentNullException("locator");
if(parameters == null)
throw new ArgumentNullException("parameters");

StringWriter sw = new StringWriter();
using(XmlTextWriter writer = new XmlTextWriter(sw))
{
writer.WriteStartElement("properties");
foreach(var parameter in parameters)
{
writer.WriteStartElement("property");
writer.WriteAttributeString("name", parameter.Key);
writer.WriteAttributeString("value", parameter.Value);
writer.WriteEndElement();
}
writer.WriteEndElement();
}

_caller.PutFormat(sw.ToString(), HttpContentTypes.ApplicationXml, "/app/rest/buildTypes/{0}/parameters", locator);
}

public void PostRawAgentRequirement(BuildTypeLocator locator, string rawXml)
{
_caller.PostFormat(rawXml, HttpContentTypes.ApplicationXml, "/app/rest/buildTypes/{0}/agent-requirements", locator);
Expand Down
15 changes: 15 additions & 0 deletions src/TeamCitySharp/ActionTypes/IBuildConfigs.cs
Expand Up @@ -69,5 +69,20 @@ public interface IBuildConfigs
BuildConfig BuildType(BuildTypeLocator locator);

void DeleteConfiguration(BuildTypeLocator locator);

/// <summary>
/// Deletes all of the parameters defined locally on this build type.
/// This spares those parameters inherited from the template, you will still get them when listing all parameters.
/// </summary>
/// <since>8.0</since>
void DeleteAllBuildTypeParameters(BuildTypeLocator locator);

/// <summary>
/// Replaces all of the parameters defined locally on this build type with the new set supplied.
/// Same as calling <see cref="DeleteAllBuildTypeParameters"/> and then <see cref="SetConfigurationParameter"/> for each entry.
/// </summary>
/// <since>8.0</since>
void PutAllBuildTypeParameters(BuildTypeLocator locator, IDictionary<string, string> parameters);

}
}

0 comments on commit 9f93503

Please sign in to comment.