Skip to content

Commit

Permalink
Merge branch 'nylchr-develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenba committed Dec 14, 2017
2 parents e468c1e + 215a0c8 commit d4ac03c
Show file tree
Hide file tree
Showing 19 changed files with 569 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,4 @@ artifacts/
.vs/YouTrackSharp/v15/sqlite3/storage.ide
.idea/.idea.YouTrackSharp/.idea/inspectionProfiles/profiles_settings.xml
.idea/.idea.YouTrackSharp/.idea/contentModel.xml
/.vs
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The following API's are currently supported:
* [Projects-related methods](https://www.jetbrains.com/help/youtrack/standalone/Projects-Related-Methods.html) through `ProjectsService`
* [Issues-related methods](https://www.jetbrains.com/help/youtrack/standalone/Issues-Related-Methods.html) through `IssuesService`
* [Time-tracking-related methods](https://www.jetbrains.com/help/youtrack/standalone/Time-Tracking-User-Methods.html) through `TimeTrackingService`
* [Agile Board-related methods](https://www.jetbrains.com/help/youtrack/standalone/Agile-Board-REST-API.html) through `AgileBoardService`
* Administration API's
* [User management](https://www.jetbrains.com/help/youtrack/standalone/Users.html) through `UserManagementService`
* [Time Tracker management](https://www.jetbrains.com/help/youtrack/standalone/Time-Tracking-Settings-Methods.html) through `TimeTrackingManagementService`
Expand Down
2 changes: 2 additions & 0 deletions YouTrackSharp.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/USE_INDENT_FROM_VS/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=DCB656ADAFF3A345B89927C656DDAFD8/@KeyIndexDefined">False</s:Boolean>
Expand Down
2 changes: 2 additions & 0 deletions build/YouTrackSharp.Build.csproj.dotsettings
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
88 changes: 88 additions & 0 deletions src/YouTrackSharp/AgileBoards/AgileBoardService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;

namespace YouTrackSharp.AgileBoards
{
public class AgileBoardService
{
private readonly Connection _connection;

/// <summary>
/// Creates an instance of the <see cref="AgileBoardService" /> class.
/// </summary>
/// <param name="connection">A <see cref="Connection" /> instance that provides a connection to the remote YouTrack server instance.</param>
public AgileBoardService(Connection connection)
{
_connection = connection ?? throw new ArgumentNullException(nameof(connection));
}

/// <summary>
/// Get a list of agile boards
/// </summary>
/// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Get-List-of-Agile-Boards.html">Get the List of Agile Boards</a>.</remarks>
/// <returns>A <see cref="T:System.Collections.Generic.ICollection`1" /> of <see cref="AgileSettings" /> that match the specified parameters.</returns>
/// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
public async Task<ICollection<AgileSettings>> GetAgileBoards()
{
var client = await _connection.GetAuthenticatedHttpClient();
var response = await client.GetAsync("rest/admin/agile");

if (response.StatusCode == HttpStatusCode.NotFound)
{
return null;
}

response.EnsureSuccessStatusCode();

return JsonConvert.DeserializeObject<ICollection<AgileSettings>>(await response.Content.ReadAsStringAsync());
}

/// <summary>
/// Get the agile board with the specified id.
/// </summary>
/// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Get-Agile-Configuration-by-ID.html">Get Agile Configuration by ID</a>.</remarks>
/// <param name="agileBoardId">Id of the agile board containing the sprint.</param>
/// <returns>An <see cref="AgileSettings" /> that match the specified parameter.</returns>
/// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
public async Task<AgileSettings> GetAgileBoard(string agileBoardId)
{
var client = await _connection.GetAuthenticatedHttpClient();
var response = await client.GetAsync($"rest/admin/agile/{agileBoardId}");

if (response.StatusCode == HttpStatusCode.NotFound)
{
return null;
}

response.EnsureSuccessStatusCode();

return JsonConvert.DeserializeObject<AgileSettings>(await response.Content.ReadAsStringAsync());
}

/// <summary>
/// Get sprint by id
/// </summary>
/// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/standalone/Get-Sprint-by-ID.html">Get Sprint by ID</a>.</remarks>
/// <param name="agileBoardId">Id of the agile board containing the sprint.</param>
/// <param name="sprintId">Id of the sprint.</param>
/// <returns>A <see cref="Sprint" /> that match the specified parameters.</returns>
/// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
public async Task<Sprint> GetSprint(string agileBoardId, string sprintId)
{
var client = await _connection.GetAuthenticatedHttpClient();
var response = await client.GetAsync($"rest/admin/agile/{agileBoardId}/sprint/{sprintId}");

if (response.StatusCode == HttpStatusCode.NotFound)
{
return null;
}

response.EnsureSuccessStatusCode();

return JsonConvert.DeserializeObject<Sprint>(await response.Content.ReadAsStringAsync());
}
}
}
84 changes: 84 additions & 0 deletions src/YouTrackSharp/AgileBoards/AgileSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace YouTrackSharp.AgileBoards
{
/// <summary>
/// A class that represents an agile board
/// </summary>
public class AgileSettings
{
/// <summary>
/// Creates an instance of the <see cref="AgileSettings" /> class.
/// </summary>
public AgileSettings()
{
Projects = new List<Project>();
Sprints = new List<Sprint>();
}

/// <summary>
/// List of <see cref="Project"/>s included on the board
/// </summary>
[JsonProperty("projects")]
public ICollection<Project> Projects { get; set; }

/// <summary>
/// The name of the agile board
/// </summary>
[JsonProperty("name")]
public string Name { get; set; }

/// <summary>
/// The internal id used by YouTrack to identify the board
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }

/// <summary>
/// The filter query used by the board
/// </summary>
[JsonProperty("query")]
public string Query { get; set; }

/// <summary>
/// The <see cref="ColumnSettings"/> used by the board
/// </summary>
[JsonProperty("columnSettings")]
public ColumnSettings ColumnSettings { get; set; }

/// <summary>
/// If time tracking is enabled this property returns the estimation field
/// </summary>
[JsonProperty("timeField")]
public Field TimeField { get; set; }

/// <summary>
/// If Cards are color coded by a field this field can be found here
/// </summary>
[JsonProperty("colorConfig")]
public ColorConfig ColorConfig { get; set; }

/// <summary>
/// I have no idea what this field means.
/// </summary>
[JsonProperty("completeBacklogHierarhy")]
public bool CompleteBacklogHierarhy { get; set; }

/// <summary>
/// The <see cref="SwimlaneSettings"/> of the board
/// </summary>
public SwimlaneSettings SwimlaneSettings { get; set; }

/// <summary>
/// The saved search that returns the backlog for the board
/// <remarks>See <see cref="Backlog"/> for more info</remarks>
/// </summary>
public Backlog Backlog { get; set; }

/// <summary>
/// The list of <see cref="Sprint"/>s associated with the board
/// </summary>
public ICollection<Sprint> Sprints { get; set; }
}
}
34 changes: 34 additions & 0 deletions src/YouTrackSharp/AgileBoards/Backlog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Newtonsoft.Json;

namespace YouTrackSharp.AgileBoards
{
/// <summary>
/// A class that represents the saved search used to get the backlog for the board
/// </summary>
public class Backlog
{
/// <summary>
/// Gets or sets the query used in the search
/// </summary>
[JsonProperty("value")]
public string Value { get; set; }

/// <summary>
/// Gets or sets the name of hte saved search
/// </summary>
[JsonProperty("name")]
public string Name { get; set; }

/// <summary>
/// Gets or sets the name of the group that can use the saved search
/// </summary>
[JsonProperty("visibleForGroup")]
public string VisibleForGroup { get; set; }

/// <summary>
/// Gets or sets the name of the group that can update the saved search
/// </summary>
[JsonProperty("updatableByGroup")]
public string UpdatableByGroup { get; set; }
}
}
16 changes: 16 additions & 0 deletions src/YouTrackSharp/AgileBoards/ColorConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;

namespace YouTrackSharp.AgileBoards
{
/// <summary>
/// A class that represents the color configuration for an agile board
/// </summary>
public class ColorConfig
{
/// <summary>
/// Gets or sets the field used to determine how to color code the cards on the board
/// </summary>
[JsonProperty("field")]
public Field Field { get; set; }
}
}
31 changes: 31 additions & 0 deletions src/YouTrackSharp/AgileBoards/ColumnSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace YouTrackSharp.AgileBoards
{
/// <summary>
/// A class that represents the column settings of a board
/// </summary>
public class ColumnSettings
{
/// <summary>
/// Creates an instance of the <see cref="ColumnSettings"/> class
/// </summary>
public ColumnSettings()
{
VisibleValues = new List<VisibleValue>();
}

/// <summary>
/// Gets or sets the field used to determine the columns of a board
/// </summary>
[JsonProperty("field")]
public Field Field { get; set; }

/// <summary>
/// A list of the <see cref="VisibleValues"/> comprising the columns of a board
/// </summary>
[JsonProperty("visibleValues")]
public ICollection<VisibleValue> VisibleValues { get; set; }
}
}
22 changes: 22 additions & 0 deletions src/YouTrackSharp/AgileBoards/Field.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Newtonsoft.Json;

namespace YouTrackSharp.AgileBoards
{
/// <summary>
/// A class that represents a YouTrack field used in the context of an agile board
/// </summary>
public class Field
{
/// <summary>
/// Gets or sets the name of the field
/// </summary>
[JsonProperty("name")]
public string Name { get; set; }

/// <summary>
/// Gets or sets the localized name of the field
/// </summary>
[JsonProperty("localizedName")]
public string LocalizedName { get; set; }
}
}
18 changes: 18 additions & 0 deletions src/YouTrackSharp/AgileBoards/Project.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;
using YouTrackSharp.Projects;

namespace YouTrackSharp.AgileBoards
{
/// <summary>
/// A class that represents a project in the context of an agile board. The class only provides an id, see <see cref="ProjectsService"/>
/// for more info on how to access a YouTrack project
/// </summary>
public class Project
{
/// <summary>
/// Gets or sets the id of a project
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }
}
}
44 changes: 44 additions & 0 deletions src/YouTrackSharp/AgileBoards/Sprint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Newtonsoft.Json;
using System;
using YouTrackSharp.Json;

namespace YouTrackSharp.AgileBoards
{
/// <summary>
/// A class that represents a sprint
/// </summary>
public class Sprint
{
/// <summary>
/// Gets or sets the id used by YouTrack to identify a sprint
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }

/// <summary>
/// Gets or sets the name of the sprint.
/// </summary>
[JsonProperty("version")]
public string Version { get; set; }

/// <summary>
/// Gets or sets the start date of the sprint
/// </summary>
[JsonConverter(typeof(UnixDateTimeOffsetConverter))]
[JsonProperty("start")]
public DateTimeOffset? Start { get; set; }

/// <summary>
/// Gets or sets the last day of the sprint
/// </summary>
[JsonConverter(typeof(UnixDateTimeOffsetConverter))]
[JsonProperty("finish")]
public DateTimeOffset? Finish { get; set; }

/// <summary>
/// Gets or sets the is default sprint status
/// </summary>
[JsonProperty("isDefault")]
public bool IsDefault { get; set; }
}
}
Loading

0 comments on commit d4ac03c

Please sign in to comment.