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

Pipeline api improvements #21

Open
wants to merge 3 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
6 changes: 6 additions & 0 deletions src/Bitbucket.Cloud.Net/Models/v2/Target.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Bitbucket.Cloud.Net.Models.v2
{
Expand All @@ -13,5 +14,10 @@ public class Target
public DateTime Date { get; set; }
public string Message { get; set; }
public string Type { get; set; }

[JsonProperty("ref_type")] public string RefType { get; set; }
[JsonProperty("ref_name")] public string RefName { get; set; }

public string Source { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ namespace Bitbucket.Cloud.Net
{
public partial class BitbucketCloudClient
{
private IFlurlRequest GetPipelinesUrl(string workspaceId, string repositorySlug) => GetBaseUrl($"2.0/repositories/{workspaceId}/{repositorySlug}/pipelines");
private IFlurlRequest GetPipelinesUrl(string workspaceId, string repositorySlug) => GetBaseUrl($"2.0/repositories/{workspaceId}/{repositorySlug}/pipelines/");

private IFlurlRequest GetPipelinesUrl(string workspaceId, string repositorySlug, Guid pipelineUuid) => GetPipelinesUrl(workspaceId, repositorySlug)
.AppendPathSegment($"/pipelines/{pipelineUuid:B}");
.AppendPathSegment($"/{pipelineUuid:B}");

private IFlurlRequest GetPipelineStepsUrl(string workspaceId, string repositorySlug, Guid pipelineUuid) => GetPipelinesUrl(workspaceId, repositorySlug, pipelineUuid)
.AppendPathSegment("/steps");
.AppendPathSegment("/steps/");

private IFlurlRequest GetPipelineStepUrl(string workspaceId, string repositorySlug, Guid pipelineUuid, string stepId) => GetPipelineStepsUrl(workspaceId, repositorySlug, pipelineUuid)
.AppendPathSegment($"/{stepId}");

public async Task<IEnumerable<Pipeline>> GetRepositoryPipelinesAsync(string workspaceId, string repositorySlug, int? maxPages = null)
public async Task<IEnumerable<Pipeline>> GetRepositoryPipelinesAsync(string workspaceId, string repositorySlug, int? maxPages = null, int? page = null, int? pageLength = null, string sort = null)
{
var queryParamValues = new Dictionary<string, object>();
var queryParamValues = new Dictionary<string, object>
{
[nameof(page)] = page,
["pagelen"] = pageLength,
[nameof(sort)] = sort
};

return await GetPagedResultsAsync(maxPages, queryParamValues, async qpv =>
await GetPipelinesUrl(workspaceId, repositorySlug)
Expand Down