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

Agile #103

Open
wants to merge 14 commits into
base: 203
Choose a base branch
from
Open

Agile #103

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
143 changes: 143 additions & 0 deletions src/YouTrackSharp/Agiles/Agile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using YouTrackSharp.Json;
using YouTrackSharp.Projects;
using YouTrackSharp.SerializationAttributes;

namespace YouTrackSharp.Agiles
{
/// <summary>
/// Represents an agile board configuration.
/// </summary>
public class Agile
{
/// <summary>
/// Id of the Agile.
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }

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

/// <summary>
/// Owner of the agile board. Can be null.
/// </summary>
[JsonProperty("owner")]
public User Owner { get; set; }

/// <summary>
/// The user group that can view this board. Can be null.
/// </summary>
[Verbose]
[JsonProperty("visibleFor")]
public UserGroup VisibleFor { get; set; }

/// <summary>
/// When true, the board is visible to everyone who can view all projects that are associated with the board.
/// </summary>
[JsonProperty("visibleForProjectBased")]
public bool VisibleForProjectBased { get; set; }

/// <summary>
/// Group of users who can update board settings. Can be null.
/// </summary>
[Verbose]
[JsonProperty("updateableBy")]
public UserGroup UpdateableBy { get; set; }

/// <summary>
/// When true, anyone who can update the associated projects can update the board.
/// </summary>
[JsonProperty("updateableByProjectBased")]
public bool UpdateableByProjectBased { get; set; }

/// <summary>
/// When true, the orphan swimlane is placed at the top of the board. Otherwise, the orphans swimlane is located
/// below all other swimlanes.
/// </summary>
[JsonProperty("orphansAtTheTop")]
public bool OrphansAtTheTop { get; set; }

/// <summary>
/// When true, the orphans swimlane is not displayed on the board.
/// </summary>
[JsonProperty("hideOrphansSwimlane")]
public bool HideOrphansSwimlane { get; set; }

/// <summary>
/// A custom field that is used as the estimation field for the board. Can be null.
/// </summary>
[Verbose]
[JsonProperty("estimationField")]
public CustomField EstimationField { get; set; }

/// <summary>
/// A custom field that is used as the original estimation field for the board. Can be null.
/// </summary>
[Verbose]
[JsonProperty("originalEstimationField")]
public CustomField OriginalEstimationField { get; set; }

/// <summary>
/// A collection of projects associated with the board.
/// </summary>
[Verbose]
[JsonProperty("projects")]
public List<Project> Projects { get; set; }

/// <summary>
/// The set of sprints that are associated with the board.
/// </summary>
[Verbose]
[JsonProperty("sprints")]
public List<Sprint> Sprints { get; set; }

/// <summary>
/// A sprint that is actual for the current date. Read-only. Can be null.
/// </summary>
[Verbose]
[JsonProperty("currentSprint")]
public Sprint CurrentSprint { get; set; }

/// <summary>
/// Column settings of the board. Read-only.
/// </summary>
[Verbose]
[JsonProperty("columnSettings")]
public ColumnSettings ColumnSettings { get; set; }

/// <summary>
/// Settings of the board swimlanes. Can be null.
/// </summary>
[Verbose]
[JsonProperty("swimlaneSettings")]
[JsonConverter(typeof(KnownTypeConverter<SwimlaneSettings>))]
public SwimlaneSettings SwimlaneSettings { get; set; }

/// <summary>
/// Settings of the board sprints. Read-only.
/// </summary>
[Verbose]
[JsonProperty("sprintsSettings")]
public SprintsSettings SprintsSettings { get; set; }

/// <summary>
/// Color coding settings for the board. Can be null.
/// </summary>
[Verbose]
[JsonProperty("colorCoding")]
[JsonConverter(typeof(KnownTypeConverter<ColorCoding>))]
public ColorCoding ColorCoding { get; set; }

/// <summary>
/// Status of the board. Read-only.
/// </summary>
[Verbose]
[JsonProperty("status")]
public AgileStatus Status { get; set; }
}
}
47 changes: 47 additions & 0 deletions src/YouTrackSharp/Agiles/AgileColumn.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace YouTrackSharp.Agiles
{
/// <summary>
/// Represents settings for a single board column
/// </summary>
public class AgileColumn
{
/// <summary>
/// Id of the AgileColumn.
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }

/// <summary>
/// Text presentation of values stored in a column. Read-only. Can be null.
/// </summary>
[JsonProperty("presentation")]
public string Presentation { get; set; }

/// <summary>
/// true if a column represents resolved state of an issue. Can be updated only for newly created value. Read-only.
/// </summary>
[JsonProperty("isResolved")]
public bool IsResolved { get; set; }

/// <summary>
/// Order of this column on board, counting from left to right.
/// </summary>
[JsonProperty("ordinal")]
public int Ordinal { get; set; }

/// <summary>
/// WIP limit for this column. Can be null.
/// </summary>
[JsonProperty("wipLimit")]
public WIPLimit WipLimit { get; set; }

/// <summary>
/// Field values represented by this column.
/// </summary>
[JsonProperty("fieldValues")]
public List<AgileColumnFieldValue> FieldValues { get; set; }
}
}
22 changes: 22 additions & 0 deletions src/YouTrackSharp/Agiles/AgileColumnFieldValue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Newtonsoft.Json;

namespace YouTrackSharp.Agiles
{
/// <summary>
/// Represents a field value or values, parameterizing agile column.
/// </summary>
public class AgileColumnFieldValue : DatabaseAttributeValue
{
/// <summary>
/// Presentation of a field value or values. Can be null.
/// </summary>
[JsonProperty("name")]
public string Name { get; set; }

/// <summary>
/// True, if field has type State and teh value is resolved or all values are resolved. Read-only.
/// </summary>
[JsonProperty("isResolved")]
public bool IsResolved { get; set; }
}
}
59 changes: 59 additions & 0 deletions src/YouTrackSharp/Agiles/AgileService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using YouTrackSharp.Internal;

namespace YouTrackSharp.Agiles
{
/// <summary>
/// Service offering Agile-related operations.
/// </summary>
public class AgileService : IAgileService
{
private readonly Connection _connection;

private readonly FieldSyntaxEncoder _fieldSyntaxEncoder;

/// <summary>
/// Creates an instance of the <see cref="AgileService"/> class.
/// </summary>
/// <param name="connection">
/// A <see cref="Connection" /> instance that provides a connection to the remote YouTrack server instance.
/// </param>
/// <param name="fieldSyntaxEncoder">
/// An <see cref="FieldSyntaxEncoder"/> instance that allows to encode types into Youtrack request URL format for fields
/// </param>
public AgileService(Connection connection, FieldSyntaxEncoder fieldSyntaxEncoder)
{
_connection = connection;
_fieldSyntaxEncoder = fieldSyntaxEncoder;
}

/// <inheritdoc />
public async Task<ICollection<Agile>> GetAgileBoards(bool verbose = false)
{
HttpClient client = await _connection.GetAuthenticatedHttpClient();

const int batchSize = 10;
List<Agile> agileBoards = new List<Agile>();
List<Agile> currentBatch;

do
{
string fields = _fieldSyntaxEncoder.Encode(typeof(Agile), verbose);

HttpResponseMessage message = await client.GetAsync($"api/agiles?fields={fields}&$top={batchSize}&$skip={agileBoards.Count}");

string response = await message.Content.ReadAsStringAsync();

currentBatch = JsonConvert.DeserializeObject<List<Agile>>(response);

agileBoards.AddRange(currentBatch);
} while (currentBatch.Count == batchSize);

return agileBoards;
}
}
}
42 changes: 42 additions & 0 deletions src/YouTrackSharp/Agiles/AgileStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace YouTrackSharp.Agiles
{
/// <summary>
/// Shows if the board has any configuration problems.
/// </summary>
public class AgileStatus
{
/// <summary>
/// Id of the AgileStatus.
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }

/// <summary>
/// true if the board is in valid state and can be used. Read-only.
/// </summary>
[JsonProperty("valid")]
public bool Valid { get; set; }

/// <summary>
/// If `true`, then a background job is currently being executed for the board. In this case, while a background
/// job is running, the board cannot be updated. Read-only.
/// </summary>
[JsonProperty("hasJobs")]
public bool HasJobs { get; set; }

/// <summary>
/// List of configuration errors found for this board. Read-only.
/// </summary>
[JsonProperty("errors")]
public List<string> Errors { get; set; }

/// <summary>
/// List of configuration-related warnings found for this board. Read-only.
/// </summary>
[JsonProperty("warnings")]
public List<string> Warnings { get; set; }
}
}
26 changes: 26 additions & 0 deletions src/YouTrackSharp/Agiles/AttributeBasedSwimlaneSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using YouTrackSharp.Json;

namespace YouTrackSharp.Agiles
{
/// <summary>
/// Settings of swimlanes that are identified by the set of values in the selected field. For example, you can set
/// swimlanes to represent issues for each Assignee.
/// </summary>
public class AttributeBasedSwimlaneSettings : SwimlaneSettings
{
/// <summary>
/// CustomField which values are used to identify swimlane.
/// </summary>
[JsonProperty("field")]
[JsonConverter(typeof(KnownTypeConverter<FilterField>))]
public FilterField Field { get; set; }

/// <summary>
/// Swimlanes that are visible on the Board.
/// </summary>
[JsonProperty("values")]
public List<SwimlaneEntityAttributeValue> Values { get; set; }
}
}
19 changes: 19 additions & 0 deletions src/YouTrackSharp/Agiles/ColorCoding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Newtonsoft.Json;
using YouTrackSharp.SerializationAttributes;

namespace YouTrackSharp.Agiles
{
/// <summary>
/// Describe rules according to which different colors are used for cards on agile board.
/// </summary>
[KnownType(typeof(FieldBasedColorCoding))]
[KnownType(typeof(ProjectBasedColorCoding))]
public class ColorCoding
{
/// <summary>
/// Id of the ColorCoding.
/// </summary>
[JsonProperty("id")]
public string Id { get; set; }
}
}
Loading