mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-05 23:06:10 +00:00
* Run `build -Target FormatCode` to fixup whitespace etc * Fix delete release asset integration test * Fix repository fork test * Fix pagination test for PR Review Request * First cut of release notes * update release notes * Update release notes * include links to contributors * Add breaking changes/advisories section * Tidy up formatting * Tidy up wording
135 lines
5.5 KiB
C#
135 lines
5.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Net;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Octokit
|
|
{
|
|
/// <summary>
|
|
/// A client for GitHub's Project Columns API.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// See the <a href="https://developer.github.com/v3/repos/projects/columns/">Repository Projects API documentation</a> for more information.
|
|
/// </remarks>
|
|
public class ProjectColumnsClient : ApiClient, IProjectColumnsClient
|
|
{
|
|
public ProjectColumnsClient(IApiConnection apiConnection) :
|
|
base(apiConnection)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all columns for this project.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// See the <a href="https://developer.github.com/v3/projects/columns/#list-project-columns">API documentation</a> for more information.
|
|
/// </remarks>
|
|
/// <param name="projectId">The Id of the project</param>
|
|
public Task<IReadOnlyList<ProjectColumn>> GetAll(int projectId)
|
|
{
|
|
return GetAll(projectId, ApiOptions.None);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets all columns for this project.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// See the <a href="https://developer.github.com/v3/projects/columns/#list-project-columns">API documentation</a> for more information.
|
|
/// </remarks>
|
|
/// <param name="projectId">The Id of the project</param>
|
|
/// <param name="options">Options for changing the API response</param>
|
|
public Task<IReadOnlyList<ProjectColumn>> GetAll(int projectId, ApiOptions options)
|
|
{
|
|
Ensure.ArgumentNotNull(options, "options");
|
|
|
|
return ApiConnection.GetAll<ProjectColumn>(ApiUrls.ProjectColumns(projectId), new Dictionary<string, string>(), AcceptHeaders.ProjectsApiPreview, options);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a single column for this project.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// See the <a href="https://developer.github.com/v3/projects/columns/#get-a-project-column">API documentation</a> for more information.
|
|
/// </remarks>
|
|
/// <param name="id">The id of the column</param>
|
|
public Task<ProjectColumn> Get(int id)
|
|
{
|
|
return ApiConnection.Get<ProjectColumn>(ApiUrls.ProjectColumn(id), null, AcceptHeaders.ProjectsApiPreview);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a column for this project.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// See the <a href="https://developer.github.com/v3/projects/columns/#create-a-project-column">API documentation</a> for more information.
|
|
/// </remarks>
|
|
/// <param name="projectId">The Id of the project</param>
|
|
/// <param name="newProjectColumn">The column to create</param>
|
|
public Task<ProjectColumn> Create(int projectId, NewProjectColumn newProjectColumn)
|
|
{
|
|
Ensure.ArgumentNotNull(newProjectColumn, "newProjectColumn");
|
|
|
|
return ApiConnection.Post<ProjectColumn>(ApiUrls.ProjectColumns(projectId), newProjectColumn, AcceptHeaders.ProjectsApiPreview);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates a column for this project.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// See the <a href="https://developer.github.com/v3/projects/columns/#update-a-project-column">API documentation</a> for more information.
|
|
/// </remarks>
|
|
/// <param name="id">The id of the column</param>
|
|
/// <param name="projectColumnUpdate">New values to update the column with</param>
|
|
public Task<ProjectColumn> Update(int id, ProjectColumnUpdate projectColumnUpdate)
|
|
{
|
|
Ensure.ArgumentNotNull(projectColumnUpdate, "projectColumnUpdate");
|
|
|
|
return ApiConnection.Patch<ProjectColumn>(ApiUrls.ProjectColumn(id), projectColumnUpdate, AcceptHeaders.ProjectsApiPreview);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Deletes a column.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// See the <a href="https://developer.github.com/v3/projects/columns/#delete-a-project-column">API documentation</a> for more information.
|
|
/// </remarks>
|
|
/// <param name="id">The id of the column</param>
|
|
public async Task<bool> Delete(int id)
|
|
{
|
|
var endpoint = ApiUrls.ProjectColumn(id);
|
|
try
|
|
{
|
|
var httpStatusCode = await Connection.Delete(endpoint, new object(), AcceptHeaders.ProjectsApiPreview).ConfigureAwait(false);
|
|
return httpStatusCode == HttpStatusCode.NoContent;
|
|
}
|
|
catch (NotFoundException)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Moves a column.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// See the <a href="https://developer.github.com/v3/repos/projects/#move-a-column">API documentation</a> for more information.
|
|
/// </remarks>
|
|
/// <param name="id">The id of the column</param>
|
|
/// <param name="position">The position to move the column</param>
|
|
public async Task<bool> Move(int id, ProjectColumnMove position)
|
|
{
|
|
Ensure.ArgumentNotNull(position, "position");
|
|
|
|
var endpoint = ApiUrls.ProjectColumnMove(id);
|
|
try
|
|
{
|
|
var httpStatusCode = await Connection.Post(endpoint, position, AcceptHeaders.ProjectsApiPreview).ConfigureAwait(false);
|
|
return httpStatusCode == HttpStatusCode.Created;
|
|
}
|
|
catch (NotFoundException)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|