diff --git a/.gitignore b/.gitignore
index 9404e7fa..7ed7f1b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,4 @@ _ReSharper*/
/packages/
!packages/repositories.config
/.vs/SharpBucket/v15/Server/sqlite3
+*.nupkg
diff --git a/ConsoleTests/ConsoleTests.csproj b/ConsoleTests/ConsoleTests.csproj
index bc64a762..324bcb4c 100644
--- a/ConsoleTests/ConsoleTests.csproj
+++ b/ConsoleTests/ConsoleTests.csproj
@@ -9,8 +9,9 @@
Properties
ConsoleTests
ConsoleTests
- v4.0
+ v4.5
512
+
AnyCPU
@@ -21,6 +22,7 @@
DEBUG;TRACE
prompt
4
+ false
AnyCPU
@@ -30,6 +32,7 @@
TRACE
prompt
4
+ false
@@ -46,6 +49,7 @@
+
diff --git a/ConsoleTests/app.config b/ConsoleTests/app.config
new file mode 100644
index 00000000..51278a45
--- /dev/null
+++ b/ConsoleTests/app.config
@@ -0,0 +1,3 @@
+
+
+
diff --git a/SharpBucket/Authentication/IAuthenticate.cs b/SharpBucket/Authentication/IAuthenticate.cs
index cea2f5e4..7dc5244d 100644
--- a/SharpBucket/Authentication/IAuthenticate.cs
+++ b/SharpBucket/Authentication/IAuthenticate.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using RestSharp;
+using Serilog;
namespace SharpBucket.Authentication
{
@@ -13,5 +14,23 @@ public virtual T GetResponse(string url, Method method, T body, IDictionary
+ /// With SeriLog logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public virtual T GetResponse(ILogger logger, string url, Method method, T body, IDictionary requestParameters)
+ {
+ var executeMethod = typeof(RequestExecutor).GetMethod("ExecuteRequestWithLogging");
+ var generic = executeMethod?.MakeGenericMethod(typeof(T));
+ return (T)generic?.Invoke(this, new object[] { logger,url, method, body, client, requestParameters
+ });
+ }
}
}
\ No newline at end of file
diff --git a/SharpBucket/Authentication/RequestExecutor.cs b/SharpBucket/Authentication/RequestExecutor.cs
index 85a269ad..9cc81e90 100644
--- a/SharpBucket/Authentication/RequestExecutor.cs
+++ b/SharpBucket/Authentication/RequestExecutor.cs
@@ -3,6 +3,8 @@
using System.Net;
using RestSharp;
using RestSharp.Deserializers;
+using Serilog;
+using SharpBucket.V2.Pocos;
namespace SharpBucket.Authentication
{
@@ -87,5 +89,67 @@ private static bool RequestingSimpleType()
{
return typeof(T) == typeof(object);
}
+
+
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static T ExecuteRequestWithLogging(ILogger logger, string url, Method method, T body, RestClient client, IDictionary requestParameters)
+ where T : new()
+ {
+ var request = new RestRequest(url, method);
+ if (requestParameters != null)
+ {
+ foreach (var requestParameter in requestParameters)
+ {
+ request.AddParameter(requestParameter.Key, requestParameter.Value);
+ }
+ }
+
+ if (ShouldAddBody(method))
+ {
+ if (body.GetType() != typeof(Branch))
+ {
+ request.RequestFormat = DataFormat.Json;
+ request.AddBody(body);
+ }
+ else
+ {
+ request.AddObject(body);
+ request.AddHeader("Content-Type", "multipart/form-data");
+ }
+ }
+
+ //Fixed bug that prevents RestClient for adding custom headers to the request
+ //https://stackoverflow.com/questions/22229393/why-is-restsharp-addheaderaccept-application-json-to-a-list-of-item
+
+ client.ClearHandlers();
+
+ client.AddHandler("application/json", new JsonDeserializer());
+
+ var result = ExectueRequest(method, client, request);
+
+ if (result.ErrorException != null)
+ {
+ throw new WebException("REST client encountered an error: " + result.ErrorMessage, result.ErrorException);
+ }
+ // This is a hack in order to allow this method to work for simple types as well
+ // one example of this is the GetRevisionRaw method
+ if (RequestingSimpleType())
+ {
+ return result.Content as dynamic;
+ }
+
+ logger.Debug($"{result.StatusCode}: {result.StatusDescription}");
+ return result.Data;
+ }
}
}
\ No newline at end of file
diff --git a/SharpBucket/SharpBucket.cs b/SharpBucket/SharpBucket.cs
index 7b5fbab4..6acc8caf 100644
--- a/SharpBucket/SharpBucket.cs
+++ b/SharpBucket/SharpBucket.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Net;
using RestSharp;
+using Serilog;
using SharpBucket.Authentication;
using SharpBucket.Utility;
@@ -119,6 +120,32 @@ private T Send(T body, Method method, string overrideUrl = null, IDictionary<
return response;
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private T Send(ILogger logger, T body, Method method, string overrideUrl = null, IDictionary requestParameters = null)
+ {
+ var relativeUrl = overrideUrl;
+ T response;
+ try
+ {
+ response = authenticator.GetResponse(logger, relativeUrl, method, body, requestParameters);
+ }
+ catch (WebException ex)
+ {
+ Console.WriteLine(ex.Message);
+ response = default(T);
+ }
+ return response;
+ }
+
internal T Get(T body, string overrideUrl, object requestParameters = null)
{
//Convert to dictionary to avoid refactoring the Send method.
@@ -126,19 +153,74 @@ internal T Get(T body, string overrideUrl, object requestParameters = null)
return Send(body, Method.GET, overrideUrl, parameterDictionary);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal T Get(ILogger logger, T body, string overrideUrl, object requestParameters = null)
+ {
+ //Convert to dictionary to avoid refactoring the Send method.
+ var parameterDictionary = requestParameters.ToDictionary();
+ return Send(logger, body, Method.GET, overrideUrl, parameterDictionary);
+ }
+
internal T Post(T body, string overrideUrl)
{
return Send(body, Method.POST, overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal T Post(ILogger logger, T body, string overrideUrl)
+ {
+ return Send(logger, body, Method.POST, overrideUrl);
+ }
+
internal T Put(T body, string overrideUrl)
{
return Send(body, Method.PUT, overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal T Put(ILogger logger, T body, string overrideUrl)
+ {
+ return Send(logger, body, Method.PUT, overrideUrl);
+ }
+
internal T Delete(T body, string overrideUrl)
{
return Send(body, Method.DELETE, overrideUrl);
}
+
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal T Delete(ILogger logger, T body, string overrideUrl)
+ {
+ return Send(logger, body, Method.DELETE, overrideUrl);
+ }
}
}
\ No newline at end of file
diff --git a/SharpBucket/SharpBucket.csproj b/SharpBucket/SharpBucket.csproj
index c550d455..760ebbbf 100644
--- a/SharpBucket/SharpBucket.csproj
+++ b/SharpBucket/SharpBucket.csproj
@@ -9,8 +9,9 @@
Properties
SharpBucket
SharpBucket
- v4.0
+ v4.5
512
+
true
@@ -20,6 +21,7 @@
DEBUG;TRACE
prompt
4
+ false
pdbonly
@@ -29,16 +31,18 @@
prompt
4
bin\Release\SharpBucket.XML
+ false
- ..\packages\Newtonsoft.Json.7.0.1\lib\net40\Newtonsoft.Json.dll
- True
+ ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll
- ..\packages\RestSharp.105.2.3\lib\net4\RestSharp.dll
- True
+ ..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll
+
+
+ ..\packages\Serilog.2.6.0\lib\net45\Serilog.dll
@@ -81,13 +85,19 @@
+
+
+
+
+
+
@@ -154,7 +164,9 @@
-
+
+ Designer
+
Designer
diff --git a/SharpBucket/V2/EndPoints/BranchResource.cs b/SharpBucket/V2/EndPoints/BranchResource.cs
index 53e9000f..1d4c976b 100644
--- a/SharpBucket/V2/EndPoints/BranchResource.cs
+++ b/SharpBucket/V2/EndPoints/BranchResource.cs
@@ -1,5 +1,6 @@
using SharpBucket.V2.Pocos;
using System.Collections.Generic;
+using Serilog;
namespace SharpBucket.V2.EndPoints
{
@@ -30,5 +31,34 @@ public List ListBranches()
{
return _repositoriesEndPoint.ListBranches(_accountName, _repository);
}
+
+ ///
+ /// With Logging
+ /// Returns a list of branches for the specific repository
+ ///
+ ///
+ public List ListBranches(ILogger logger)
+ {
+ return _repositoriesEndPoint.ListBranches(logger, _accountName, _repository);
+ }
+
+ ///
+ /// Posts a new branch for the specific repository
+ ///
+ ///
+ public void PostBranch(Branch branch)
+ {
+ _repositoriesEndPoint.PostBranch(_accountName, _repository, branch);
+ }
+
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ public void PostBranch(ILogger logger, Branch branch)
+ {
+ _repositoriesEndPoint.PostBranch(logger, _accountName, _repository, branch);
+ }
}
}
\ No newline at end of file
diff --git a/SharpBucket/V2/EndPoints/EndPoint.cs b/SharpBucket/V2/EndPoints/EndPoint.cs
index a088c107..94a1a69a 100644
--- a/SharpBucket/V2/EndPoints/EndPoint.cs
+++ b/SharpBucket/V2/EndPoints/EndPoint.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Dynamic;
+using Serilog;
namespace SharpBucket.V2.EndPoints
{
@@ -57,6 +58,46 @@ private IEnumerable> IteratePages(string overrideUrl, int p
while (!String.IsNullOrEmpty(response.next));
}
+ ///
+ /// Generator that allows lazy access to paginated resources.
+ /// With logging.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private IEnumerable> IteratePages(ILogger logger, string overrideUrl, int pageLen = DEFAULT_PAGE_LEN,
+ IDictionary requestParameters = null)
+ {
+ Debug.Assert(!String.IsNullOrEmpty(overrideUrl));
+ //Debug.Assert(!overrideUrl.Contains("?"));
+
+ if (requestParameters == null)
+ {
+ requestParameters = new Dictionary();
+ }
+
+ requestParameters["pagelen"] = pageLen;
+
+ IteratorBasedPage response;
+ int page = 1;
+ do
+ {
+ response = _sharpBucketV2.Get(logger, new IteratorBasedPage(),
+ overrideUrl.Replace(SharpBucketV2.BITBUCKET_URL, ""), requestParameters);
+ if (response == null)
+ {
+ break;
+ }
+
+ yield return response.values;
+
+ requestParameters["page"] = ++page;
+ } while (!String.IsNullOrEmpty(response.next));
+ }
+
///
/// Returns a list of paginated values.
///
@@ -94,5 +135,45 @@ protected List GetPaginatedValues(string overrideUrl, int max =
return values;
}
+
+ ///
+ /// Returns a list of paginated values with Logging.
+ ///
+ /// The type of the value.
+ ///
+ /// The override URL.
+ /// Set to 0 for unlimited size.
+ ///
+ ///
+ /// Thrown when the server fails to respond.
+ protected List GetPaginatedValues(ILogger logger, string overrideUrl, int max = 0, IDictionary requestParameters = null)
+ {
+ bool isMaxConstrained = max > 0;
+
+ int pageLen = (isMaxConstrained && max < DEFAULT_PAGE_LEN) ? max : DEFAULT_PAGE_LEN;
+
+ List values = new List();
+
+ foreach (var page in IteratePages(logger, overrideUrl, pageLen, requestParameters))
+ {
+ if (page == null)
+ {
+ break;
+ }
+
+ if (isMaxConstrained &&
+ +values.Count + page.Count >= max)
+ {
+ values.AddRange(page.GetRange(0, max - values.Count));
+ Debug.Assert(values.Count == max);
+ break;
+ }
+
+ values.AddRange(page);
+ }
+
+ return values;
+ }
+
}
}
\ No newline at end of file
diff --git a/SharpBucket/V2/EndPoints/RepositoriesEndPoint.cs b/SharpBucket/V2/EndPoints/RepositoriesEndPoint.cs
index 681462a4..2fd26eaa 100644
--- a/SharpBucket/V2/EndPoints/RepositoriesEndPoint.cs
+++ b/SharpBucket/V2/EndPoints/RepositoriesEndPoint.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using System.Net;
+using Serilog;
using SharpBucket.V2.Pocos;
using Comment = SharpBucket.V2.Pocos.Comment;
using Repository = SharpBucket.V2.Pocos.Repository;
@@ -35,6 +37,22 @@ public List ListRepositories(string accountName, int max = 0)
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging.
+ /// List of repositories associated with an account and project. If the caller is properly authenticated and authorized,
+ /// this method returns a collection containing public and private repositories.
+ /// Otherwise, this method returns a collection of the public repositories.
+ ///
+ ///
+ /// The account whose repositories you wish to get.
+ /// The maximum number of items to return. 0 returns all items.
+ ///
+ public List ListRepositories(ILogger logger, string accountName, int max = 0)
+ {
+ var overrideUrl = _baseUrl + accountName + "/";
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
///
/// List of all the public repositories on Bitbucket. This produces a paginated response.
/// Pagination only goes forward (it's not possible to navigate to previous pages) and navigation is done by following the URL for the next page.
@@ -47,6 +65,49 @@ public List ListPublicRepositories(int max = 0)
return GetPaginatedValues(_baseUrl, max);
}
+ ///
+ /// With Logging.
+ /// List of all the public repositories on Bitbucket. This produces a paginated response.
+ /// Pagination only goes forward (it's not possible to navigate to previous pages) and navigation is done by following the URL for the next page.
+ /// The returned repositories are ordered by creation date, oldest repositories first. Only public repositories are returned.
+ ///
+ ///
+ /// The maximum number of items to return. 0 returns all items.
+ ///
+ public List ListPublicRepositories(ILogger logger, int max = 0)
+ {
+ return GetPaginatedValues(logger, _baseUrl, max);
+ }
+
+
+ ///
+ /// Post a new branch
+ ///
+ ///
+ ///
+ ///
+ ///
+ public Branch PostBranch(string accountName, string repository, Branch branch)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "src/");
+ return _sharpBucketV2.Post(branch, overrideUrl);
+ }
+
+
+ ///
+ /// Post a new branch with Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public Branch PostBranch(ILogger logger, string accountName, string repository, Branch branch)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "src/");
+ return _sharpBucketV2.Post(logger, branch, overrideUrl);
+ }
+
#endregion
#region Repository resource
@@ -71,24 +132,78 @@ internal Repository GetRepository(string accountName, string repository)
return _sharpBucketV2.Get(new Repository(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal Repository GetRepository(ILogger logger, string accountName, string repository)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, null);
+ return _sharpBucketV2.Get(logger, new Repository(), overrideUrl);
+ }
+
internal Repository PutRepository(Repository repo, string accountName, string repository)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, null);
return _sharpBucketV2.Put(repo, overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal Repository PutRepository(ILogger logger, Repository repo, string accountName, string repository)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, null);
+ return _sharpBucketV2.Put(repo, overrideUrl);
+ }
+
internal Repository PostRepository(Repository repo, string accountName)
{
- var overrideUrl = GetRepositoryUrl(accountName, repo.name, null);
+ var overrideUrl = GetRepositoryUrl(accountName, repo.name.ToLowerInvariant(), null);
return _sharpBucketV2.Post(repo, overrideUrl);
}
- internal Repository DeleteRepository(string accountName, string repository)
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal Repository PostRepository(ILogger logger, Repository repo, string accountName)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repo.name.ToLowerInvariant(), null);
+ return _sharpBucketV2.Post(logger, repo, overrideUrl);
+ }
+
+ internal HttpStatusCode DeleteRepository(string accountName, string repository)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, null);
- return _sharpBucketV2.Delete(new Repository(), overrideUrl);
+ return _sharpBucketV2.Delete(new HttpStatusCode(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal HttpStatusCode DeleteRepository(ILogger logger, string accountName, string repository)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, null);
+ return _sharpBucketV2.Delete(logger, new HttpStatusCode(), overrideUrl);
+ }
+
+
private string GetRepositoryUrl(string accountName, string repository, string append)
{
var format = _baseUrl + "{0}/{1}/{2}";
@@ -101,12 +216,40 @@ internal List ListWatchers(string accountName, string repository, int m
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List ListWatchers(ILogger logger, string accountName, string repository, int max = 0)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "watchers");
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
internal List ListForks(string accountName, string repository, int max = 0)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "forks");
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List ListForks(ILogger logger, string accountName, string repository, int max = 0)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "forks");
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
#endregion
#region Pull Requests Resource
@@ -122,24 +265,82 @@ internal List ListPullRequests(string accountName, string repositor
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List ListPullRequests(ILogger logger, string accountName, string repository, int max)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/");
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
internal PullRequest PostPullRequest(string accountName, string repository, PullRequest pullRequest)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/");
return _sharpBucketV2.Post(pullRequest, overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal PullRequest PostPullRequest(ILogger logger, string accountName, string repository,
+ PullRequest pullRequest)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/");
+ return _sharpBucketV2.Post(logger, pullRequest, overrideUrl);
+ }
+
internal PullRequest PutPullRequest(string accountName, string repository, PullRequest pullRequest)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/");
return _sharpBucketV2.Put(pullRequest, overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal PullRequest PutPullRequest(ILogger logger, string accountName, string repository,
+ PullRequest pullRequest)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/");
+ return _sharpBucketV2.Put(logger, pullRequest, overrideUrl);
+ }
+
internal List GetPullRequestLog(string accountName, string repository, int max = 0)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/activity/");
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List GetPullRequestLog(ILogger logger, string accountName, string repository, int max = 0)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/activity/");
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
#endregion
#region Pull Request Resource
@@ -150,60 +351,218 @@ internal PullRequest GetPullRequest(string accountName, string repository, int p
return _sharpBucketV2.Get(new PullRequest(), overrideUrl);
}
- internal List ListPullRequestCommits(string accountName, string repository, int pullRequestId, int max = 0)
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal PullRequest GetPullRequest(ILogger logger, string accountName, string repository, int pullRequestId)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/");
+ return _sharpBucketV2.Get(logger, new PullRequest(), overrideUrl);
+ }
+
+
+ internal List ListPullRequestCommits(string accountName, string repository, int pullRequestId,
+ int max = 0)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/commits/");
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List ListPullRequestCommits(ILogger logger, string accountName, string repository,
+ int pullRequestId, int max = 0)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/commits/");
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
+
internal PullRequestInfo ApprovePullRequest(string accountName, string repository, int pullRequestId)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/approve/");
return _sharpBucketV2.Post(new PullRequestInfo(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal PullRequestInfo ApprovePullRequest(ILogger logger, string accountName, string repository,
+ int pullRequestId)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/approve/");
+ return _sharpBucketV2.Post(logger, new PullRequestInfo(), overrideUrl);
+ }
+
internal object RemovePullRequestApproval(string accountName, string repository, int pullRequestId)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/approve/");
return _sharpBucketV2.Delete(new PullRequestInfo(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal object RemovePullRequestApproval(ILogger logger, string accountName, string repository,
+ int pullRequestId)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/approve/");
+ return _sharpBucketV2.Delete(logger, new PullRequestInfo(), overrideUrl);
+ }
+
internal object GetDiffForPullRequest(string accountName, string repository, int pullRequestId)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/diff/");
return _sharpBucketV2.Get(new Object(), overrideUrl);
}
- internal List GetPullRequestActivity(string accountName, string repository, int pullRequestId, int max = 0)
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal object GetDiffForPullRequest(ILogger logger, string accountName, string repository, int pullRequestId)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/diff/");
+ return _sharpBucketV2.Get(logger, new Object(), overrideUrl);
+ }
+
+ internal List GetPullRequestActivity(string accountName, string repository, int pullRequestId,
+ int max = 0)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/activity/");
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List GetPullRequestActivity(ILogger logger, string accountName, string repository,
+ int pullRequestId, int max = 0)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/activity/");
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
internal Merge AcceptAndMergePullRequest(string accountName, string repository, int pullRequestId)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/merge/");
return _sharpBucketV2.Post(new Merge(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal Merge AcceptAndMergePullRequest(ILogger logger, string accountName, string repository,
+ int pullRequestId)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/merge/");
+ return _sharpBucketV2.Post(logger, new Merge(), overrideUrl);
+ }
+
internal Merge DeclinePullRequest(string accountName, string repository, int pullRequestId)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/decline/");
return _sharpBucketV2.Get(new Merge(), overrideUrl);
}
- internal List ListPullRequestComments(string accountName, string repository, int pullRequestId, int max = 0)
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal Merge DeclinePullRequest(ILogger logger, string accountName, string repository, int pullRequestId)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/decline/");
+ return _sharpBucketV2.Get(logger, new Merge(), overrideUrl);
+ }
+
+ internal List ListPullRequestComments(string accountName, string repository, int pullRequestId,
+ int max = 0)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/comments/");
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List ListPullRequestComments(ILogger logger, string accountName, string repository,
+ int pullRequestId, int max = 0)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/comments/");
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
internal Comment GetPullRequestComment(string accountName, string repository, int pullRequestId, int commentId)
{
- var overrideUrl = GetRepositoryUrl(accountName, repository, "pullrequests/" + pullRequestId + "/comments/" + commentId + "/");
+ var overrideUrl = GetRepositoryUrl(accountName, repository,
+ "pullrequests/" + pullRequestId + "/comments/" + commentId + "/");
return _sharpBucketV2.Get(new Comment(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal Comment GetPullRequestComment(ILogger logger, string accountName, string repository, int pullRequestId,
+ int commentId)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository,
+ "pullrequests/" + pullRequestId + "/comments/" + commentId + "/");
+ return _sharpBucketV2.Get(logger, new Comment(), overrideUrl);
+ }
+
#endregion
#region Branch Restrictions resource
@@ -214,28 +573,105 @@ internal List ListBranchRestrictions(string accountName, stri
return GetPaginatedValues(overrideUrl, max);
}
- internal BranchRestriction PostBranchRestriction(string accountName, string repository, BranchRestriction restriction)
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List ListBranchRestrictions(ILogger logger, string accountName, string repository,
+ int max = 0)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "branch-restrictions/");
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
+ internal BranchRestriction PostBranchRestriction(string accountName, string repository,
+ BranchRestriction restriction)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "branch-restrictions/");
return _sharpBucketV2.Post(restriction, overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal BranchRestriction PostBranchRestriction(ILogger logger, string accountName, string repository,
+ BranchRestriction restriction)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "branch-restrictions/");
+ return _sharpBucketV2.Post(logger, restriction, overrideUrl);
+ }
+
internal BranchRestriction GetBranchRestriction(string accountName, string repository, int restrictionId)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "branch-restrictions/" + restrictionId);
return _sharpBucketV2.Get(new BranchRestriction(), overrideUrl);
}
- internal BranchRestriction PutBranchRestriction(string accountName, string repository, BranchRestriction restriction)
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal BranchRestriction GetBranchRestriction(ILogger logger, string accountName, string repository,
+ int restrictionId)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "branch-restrictions/" + restrictionId);
+ return _sharpBucketV2.Get(logger, new BranchRestriction(), overrideUrl);
+ }
+
+ internal BranchRestriction PutBranchRestriction(string accountName, string repository,
+ BranchRestriction restriction)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "branch-restrictions/" + restriction.id);
return _sharpBucketV2.Put(restriction, overrideUrl);
}
- internal BranchRestriction DeleteBranchRestriction(string accountName, string repository, int restrictionId)
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal BranchRestriction PutBranchRestriction(ILogger logger, string accountName, string repository,
+ BranchRestriction restriction)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "branch-restrictions/" + restriction.id);
+ return _sharpBucketV2.Put(logger, restriction, overrideUrl);
+ }
+
+ internal HttpStatusCode DeleteBranchRestriction(string accountName, string repository, int restrictionId)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "branch-restrictions/" + restrictionId);
+ return _sharpBucketV2.Delete(new HttpStatusCode(), overrideUrl);
+ }
+
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal HttpStatusCode DeleteBranchRestriction(ILogger logger, string accountName, string repository,
+ int restrictionId)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "branch-restrictions/" + restrictionId);
- return _sharpBucketV2.Delete(new BranchRestriction(), overrideUrl);
+ return _sharpBucketV2.Delete(logger, new HttpStatusCode(), overrideUrl);
}
#endregion
@@ -248,12 +684,40 @@ internal object GetDiff(string accountName, string repository, object options)
return _sharpBucketV2.Get(new object(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal object GetDiff(ILogger logger, string accountName, string repository, object options)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "diff/" + options);
+ return _sharpBucketV2.Get(logger, new object(), overrideUrl);
+ }
+
internal object GetPatch(string accountName, string repository, object options)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "patch/" + options);
return _sharpBucketV2.Get(new object(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal object GetPatch(ILogger logger, string accountName, string repository, object options)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "patch/" + options);
+ return _sharpBucketV2.Get(logger, new object(), overrideUrl);
+ }
+
#endregion
#region Commits Resource
@@ -265,57 +729,209 @@ internal List ListCommits(string accountName, string repository, string
{
overrideUrl += branchortag;
}
+
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List ListCommits(ILogger logger, string accountName, string repository,
+ string branchortag = null, int max = 0)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "commits/");
+ if (!string.IsNullOrEmpty(branchortag))
+ {
+ overrideUrl += branchortag;
+ }
+
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
internal Commit GetCommit(string accountName, string repository, string revision)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "commit/" + revision);
return _sharpBucketV2.Get(new Commit(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal Commit GetCommit(ILogger logger, string accountName, string repository, string revision)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "commit/" + revision);
+ return _sharpBucketV2.Get(logger, new Commit(), overrideUrl);
+ }
+
internal List ListCommitComments(string accountName, string repository, string revision, int max = 0)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "commits/" + revision + "/comments/");
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List ListCommitComments(ILogger logger, string accountName, string repository,
+ string revision, int max = 0)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "commits/" + revision + "/comments/");
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
internal object GetCommitComment(string accountName, string repository, string revision, int commentId)
{
- var overrideUrl = GetRepositoryUrl(accountName, repository, "commits/" + revision + "/comments/" + revision + "/" + commentId + "/");
+ var overrideUrl = GetRepositoryUrl(accountName, repository,
+ "commits/" + revision + "/comments/" + revision + "/" + commentId + "/");
return _sharpBucketV2.Get(new object(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal object GetCommitComment(ILogger logger, string accountName, string repository, string revision,
+ int commentId)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository,
+ "commits/" + revision + "/comments/" + revision + "/" + commentId + "/");
+ return _sharpBucketV2.Get(logger, new object(), overrideUrl);
+ }
+
internal object ApproveCommit(string accountName, string repository, string revision)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "commits/" + revision + "/approve/");
return _sharpBucketV2.Post(new object(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal object ApproveCommit(ILogger logger, string accountName, string repository, string revision)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "commits/" + revision + "/approve/");
+ return _sharpBucketV2.Post(logger, new object(), overrideUrl);
+ }
+
internal object DeleteCommitApproval(string accountName, string repository, string revision)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "commits/" + revision + "/approve/");
return _sharpBucketV2.Delete(new object(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal object DeleteCommitApproval(ILogger logger, string accountName, string repository, string revision)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "commits/" + revision + "/approve/");
+ return _sharpBucketV2.Delete(logger, new object(), overrideUrl);
+ }
+
internal object AddNewBuildStatus(string accountName, string repository, string revision, BuildInfo buildInfo)
{
var overrideUrl = GetRepositoryUrl(accountName, repository, "commit/" + revision + "/statuses/build/");
return _sharpBucketV2.Post(buildInfo, overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal object AddNewBuildStatus(ILogger logger, string accountName, string repository, string revision,
+ BuildInfo buildInfo)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "commit/" + revision + "/statuses/build/");
+ return _sharpBucketV2.Post(logger, buildInfo, overrideUrl);
+ }
+
internal BuildInfo GetBuildStatusInfo(string accountName, string repository, string revision, string key)
{
- var overrideUrl = GetRepositoryUrl(accountName, repository, "commit/" + revision + "/statuses/build/" + key);
+ var overrideUrl =
+ GetRepositoryUrl(accountName, repository, "commit/" + revision + "/statuses/build/" + key);
return _sharpBucketV2.Get(new BuildInfo(), overrideUrl);
}
- internal object ChangeBuildStatusInfo(string accountName, string repository, string revision, string key, BuildInfo buildInfo)
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal BuildInfo GetBuildStatusInfo(ILogger logger, string accountName, string repository, string revision,
+ string key)
+ {
+ var overrideUrl =
+ GetRepositoryUrl(accountName, repository, "commit/" + revision + "/statuses/build/" + key);
+ return _sharpBucketV2.Get(logger, new BuildInfo(), overrideUrl);
+ }
+
+ internal object ChangeBuildStatusInfo(string accountName, string repository, string revision, string key,
+ BuildInfo buildInfo)
{
- var overrideUrl = GetRepositoryUrl(accountName, repository, "commit/" + revision + "/statuses/build/" + key);
+ var overrideUrl =
+ GetRepositoryUrl(accountName, repository, "commit/" + revision + "/statuses/build/" + key);
return _sharpBucketV2.Put(buildInfo, overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal object ChangeBuildStatusInfo(ILogger logger, string accountName, string repository, string revision,
+ string key, BuildInfo buildInfo)
+ {
+ var overrideUrl =
+ GetRepositoryUrl(accountName, repository, "commit/" + revision + "/statuses/build/" + key);
+ return _sharpBucketV2.Put(logger, buildInfo, overrideUrl);
+ }
+
#endregion
#region Default Reviewer Resource
@@ -326,6 +942,19 @@ internal object PutDefaultReviewer(string accountName, string repository, string
return _sharpBucketV2.Put(new object(), overrideUrl);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal object PutDefaultReviewer(ILogger logger, string accountName, string repository, string targetUsername)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "default-reviewers/" + targetUsername);
+ return _sharpBucketV2.Put(logger, new object(), overrideUrl);
+ }
+
#endregion
#region Branch Resource
@@ -341,6 +970,20 @@ internal List ListBranches(string accountName, string repository, int ma
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List ListBranches(ILogger logger, string accountName, string repository, int max = 0)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "refs/branches/");
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
#endregion
#region Tag Resource
@@ -356,6 +999,21 @@ internal List ListTags(string accountName, string repository, int max = 0)
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ internal List ListTags(ILogger logger, string accountName, string repository, int max = 0)
+ {
+ var overrideUrl = GetRepositoryUrl(accountName, repository, "refs/tags/");
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
#endregion
+
}
}
\ No newline at end of file
diff --git a/SharpBucket/V2/EndPoints/RepositoryResource.cs b/SharpBucket/V2/EndPoints/RepositoryResource.cs
index 3baf7979..35af1c77 100644
--- a/SharpBucket/V2/EndPoints/RepositoryResource.cs
+++ b/SharpBucket/V2/EndPoints/RepositoryResource.cs
@@ -1,4 +1,6 @@
using System.Collections.Generic;
+using System.Net;
+using Serilog;
using SharpBucket.V2.Pocos;
namespace SharpBucket.V2.EndPoints
@@ -34,19 +36,73 @@ public Repository GetRepository()
return _repositoriesEndPoint.GetRepository(_accountName, _repository);
}
+ ///
+ /// With Logging.
+ /// Returns a single repository.
+ ///
+ ///
+ public Repository GetRepository(ILogger logger)
+ {
+ return _repositoriesEndPoint.GetRepository(logger, _accountName, _repository);
+ }
+
///
/// Removes a repository.
///
///
- public Repository DeleteRepository()
+ public HttpStatusCode DeleteRepository()
{
return _repositoriesEndPoint.DeleteRepository(_accountName, _repository);
}
+
+ ///
+ /// With Logging.
+ /// Removes a repository.
+ ///
+ ///
+ ///
+ public HttpStatusCode DeleteRepository(ILogger logger)
+ {
+ return _repositoriesEndPoint.DeleteRepository(logger, _accountName, _repository);
+ }
+
public Repository PostRepository(Repository repository)
{
return _repositoriesEndPoint.PostRepository(repository, _accountName);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ public Repository PostRepository(ILogger logger, Repository repository)
+ {
+ return _repositoriesEndPoint.PostRepository(logger, repository, _accountName);
+ }
+
+
+ ///
+ /// Put a specific repository
+ ///
+ ///
+ ///
+ public Repository PutRepository(Repository repository)
+ {
+ return _repositoriesEndPoint.PutRepository(repository, _accountName, repository.name.ToLowerInvariant());
+ }
+
+ ///
+ /// Put a specific repository
+ ///
+ ///
+ ///
+ ///
+ public Repository PutRepository(ILogger logger, Repository repository)
+ {
+ return _repositoriesEndPoint.PutRepository(logger, repository, _accountName, repository.name.ToLowerInvariant());
+ }
///
/// Gets the list of accounts watching a repository.
@@ -57,6 +113,15 @@ public List ListWatchers()
return _repositoriesEndPoint.ListWatchers(_accountName, _repository);
}
+ ///
+ /// Gets the list of accounts watching a repository.
+ ///
+ ///
+ public List ListWatchers(ILogger logger)
+ {
+ return _repositoriesEndPoint.ListWatchers(logger, _accountName, _repository);
+ }
+
///
/// List of repository forks, This call returns a repository object for each fork.
///
@@ -66,6 +131,15 @@ public List ListForks()
return _repositoriesEndPoint.ListForks(_accountName, _repository);
}
+ ///
+ /// List of repository forks, This call returns a repository object for each fork.
+ ///
+ ///
+ public List ListForks(ILogger logger)
+ {
+ return _repositoriesEndPoint.ListForks(logger, _accountName, _repository);
+ }
+
#endregion
#region Pull Requests Resource
@@ -94,11 +168,23 @@ public PullRequestsResource PullRequestsResource()
/// List the information associated with a repository's branch restrictions.
///
///
- public object ListBranchRestrictions()
+ public List ListBranchRestrictions()
{
return _repositoriesEndPoint.ListBranchRestrictions(_accountName, _repository);
}
+ /// More info:
+ /// https://confluence.atlassian.com/display/BITBUCKET/branch-restrictions+Resource
+ ///
+ /// With Logging.
+ /// List the information associated with a repository's branch restrictions.
+ ///
+ ///
+ public List ListBranchRestrictions(ILogger logger)
+ {
+ return _repositoriesEndPoint.ListBranchRestrictions(logger, _accountName, _repository);
+ }
+
///
/// Creates restrictions for the specified repository. You should specify a Content-Header with this call.
///
@@ -109,16 +195,40 @@ public BranchRestriction PostBranchRestriction(BranchRestriction restriction)
return _repositoriesEndPoint.PostBranchRestriction(_accountName, _repository, restriction);
}
+ ///
+ /// With Logging.
+ /// Creates restrictions for the specified repository. You should specify a Content-Header with this call.
+ ///
+ ///
+ /// The branch restriction.
+ ///
+ public BranchRestriction PostBranchRestriction(ILogger logger, BranchRestriction restriction)
+ {
+ return _repositoriesEndPoint.PostBranchRestriction(logger, _accountName, _repository, restriction);
+ }
+
///
/// Gets the information associated with specific restriction.
///
/// The restriction's identifier.
///
- public object GetBranchRestriction(int restrictionId)
+ public BranchRestriction GetBranchRestriction(int restrictionId)
{
return _repositoriesEndPoint.GetBranchRestriction(_accountName, _repository, restrictionId);
}
+ ///
+ /// With Logging.
+ /// Gets the information associated with specific restriction.
+ ///
+ ///
+ /// The restriction's identifier.
+ ///
+ public BranchRestriction GetBranchRestriction(ILogger logger, int restrictionId)
+ {
+ return _repositoriesEndPoint.GetBranchRestriction(logger, _accountName, _repository, restrictionId);
+ }
+
///
/// Updates a specific branch restriction. You cannot change the kind value with this call.
///
@@ -129,15 +239,37 @@ public BranchRestriction PutBranchRestriction(BranchRestriction restriction)
return _repositoriesEndPoint.PutBranchRestriction(_accountName, _repository, restriction);
}
+ ///
+ /// With Logging
+ /// Updates a specific branch restriction. You cannot change the kind value with this call.
+ ///
+ ///
+ /// The branch restriction.
+ ///
+ public BranchRestriction PutBranchRestriction(ILogger logger, BranchRestriction restriction)
+ {
+ return _repositoriesEndPoint.PutBranchRestriction(logger, _accountName, _repository, restriction);
+ }
+
///
/// Deletes the specified restriction.
///
/// The restriction's identifier.
///
- public object DeleteBranchRestriction(int restrictionId)
+ public HttpStatusCode DeleteBranchRestriction(int restrictionId)
{
return _repositoriesEndPoint.DeleteBranchRestriction(_accountName, _repository, restrictionId);
}
+ ///
+ /// With Logging
+ /// Deletes the specified restriction.
+ ///
+ /// The restriction's identifier.
+ ///
+ public HttpStatusCode DeleteBranchRestriction(ILogger logger, int restrictionId)
+ {
+ return _repositoriesEndPoint.DeleteBranchRestriction(logger, _accountName, _repository, restrictionId);
+ }
#endregion
@@ -155,6 +287,20 @@ public object GetDiff(object options)
return _repositoriesEndPoint.GetDiff(_accountName, _repository, options);
}
+ /// More info:
+ /// https://confluence.atlassian.com/display/BITBUCKET/diff+Resource
+ ///
+ /// With Logging
+ /// Gets the diff for the current repository.
+ ///
+ ///
+ /// The diff options.
+ ///
+ public object GetDiff(ILogger logger, object options)
+ {
+ return _repositoriesEndPoint.GetDiff(logger, _accountName, _repository, options);
+ }
+
///
/// Gets the patch for an individual specification.
///
@@ -165,6 +311,18 @@ public object GetPatch(object options)
return _repositoriesEndPoint.GetPatch(_accountName, _repository, options);
}
+ ///
+ /// With Logging
+ /// Gets the patch for an individual specification.
+ ///
+ ///
+ /// The patch options.
+ ///
+ public object GetPatch(ILogger logger, object options)
+ {
+ return _repositoriesEndPoint.GetPatch(logger, _accountName, _repository, options);
+ }
+
#endregion
#region Commits resource
@@ -182,6 +340,21 @@ public List ListCommits(string branchortag = null, int max = 0)
{
return _repositoriesEndPoint.ListCommits(_accountName, _repository, branchortag, max);
}
+ /// More info:
+ /// https://confluence.atlassian.com/display/BITBUCKET/commits+or+commit+Resource
+ ///
+ /// Gets the commit information associated with a repository.
+ /// By default, this call returns all the commits across all branches, bookmarks, and tags. The newest commit is first.
+ /// With Logging
+ ///
+ ///
+ /// The branch or tag to get, for example, master or default.
+ /// Values greater than 0 will set a maximum number of records to return. 0 or less returns all.
+ ///
+ public List ListCommits(ILogger logger, string branchortag = null, int max = 0)
+ {
+ return _repositoriesEndPoint.ListCommits(logger, _accountName, _repository, branchortag, max);
+ }
///
/// Gets the information associated with an individual commit.
@@ -193,6 +366,18 @@ public Commit GetCommit(string revision)
return _repositoriesEndPoint.GetCommit(_accountName, _repository, revision);
}
+ ///
+ /// Gets the information associated with an individual commit.
+ /// With Logging
+ ///
+ ///
+ /// The commit's SHA1.
+ ///
+ public Commit GetCommit(ILogger logger, string revision)
+ {
+ return _repositoriesEndPoint.GetCommit(logger, _accountName, _repository, revision);
+ }
+
///
/// List of comments on the specified commit.
///
@@ -203,6 +388,18 @@ public List ListCommitComments(string revision)
return _repositoriesEndPoint.ListCommitComments(_accountName, _repository, revision);
}
+ ///
+ /// List of comments on the specified commit.
+ /// With Logging
+ ///
+ ///
+ /// The commit's SHA1.
+ ///
+ public List ListCommitComments(ILogger logger, string revision)
+ {
+ return _repositoriesEndPoint.ListCommitComments(logger, _accountName, _repository, revision);
+ }
+
///
/// To get an individual commit comment, just follow the object's self link.
///
@@ -214,6 +411,19 @@ public object GetCommitComment(string revision, int commentId)
return _repositoriesEndPoint.GetCommitComment(_accountName, _repository, revision, commentId);
}
+ ///
+ /// To get an individual commit comment, just follow the object's self link.
+ /// With Logging
+ ///
+ ///
+ /// The commit's SHA1.
+ /// The comment identifier.
+ ///
+ public object GetCommitComment(ILogger logger, string revision, int commentId)
+ {
+ return _repositoriesEndPoint.GetCommitComment(logger, _accountName, _repository, revision, commentId);
+ }
+
///
/// Give your approval on a commit.
/// You can only approve a comment on behalf of the authenticated account. This returns the participant object for the current user.
@@ -225,6 +435,19 @@ public object ApproveCommit(string revision)
return _repositoriesEndPoint.ApproveCommit(_accountName, _repository, revision);
}
+ ///
+ /// Give your approval on a commit.
+ /// You can only approve a comment on behalf of the authenticated account. This returns the participant object for the current user.
+ /// With Logging
+ ///
+ ///
+ /// The commit's SHA1.
+ ///
+ public object ApproveCommit(ILogger logger, string revision)
+ {
+ return _repositoriesEndPoint.ApproveCommit(logger, _accountName, _repository, revision);
+ }
+
///
/// Revoke your approval of a commit. You can remove approvals on behalf of the authenticated account.
///
@@ -235,6 +458,18 @@ public object DeleteCommitApproval(string revision)
return _repositoriesEndPoint.DeleteCommitApproval(_accountName, _repository, revision);
}
+ ///
+ /// Revoke your approval of a commit. You can remove approvals on behalf of the authenticated account.
+ /// With Logging
+ ///
+ ///
+ /// The commit's SHA1.
+ ///
+ public object DeleteCommitApproval(ILogger logger, string revision)
+ {
+ return _repositoriesEndPoint.DeleteCommitApproval(logger, _accountName, _repository, revision);
+ }
+
///
/// Creates a new build status against the specified commit. If the specified key already exists, the existing status object will be overwritten.
///
@@ -246,6 +481,19 @@ public object AddNewBuildStatus(string revision, BuildInfo buildInfo)
return _repositoriesEndPoint.AddNewBuildStatus(_accountName, _repository, revision, buildInfo);
}
+ ///
+ /// Creates a new build status against the specified commit. If the specified key already exists, the existing status object will be overwritten.
+ /// With Logging
+ ///
+ ///
+ /// The commit's SHA1
+ /// The new commit status object
+ ///
+ public object AddNewBuildStatus(ILogger logger, string revision, BuildInfo buildInfo)
+ {
+ return _repositoriesEndPoint.AddNewBuildStatus(logger, _accountName, _repository, revision, buildInfo);
+ }
+
///
/// Returns the specified build status for a commit.
///
@@ -257,6 +505,19 @@ public BuildInfo GetBuildStatusInfo(string revision, string key)
return _repositoriesEndPoint.GetBuildStatusInfo(_accountName, _repository, revision, key);
}
+ ///
+ /// Returns the specified build status for a commit.
+ /// With Logging
+ ///
+ ///
+ /// The commit's SHA1
+ /// The build status' unique key
+ ///
+ public BuildInfo GetBuildStatusInfo(ILogger logger, string revision, string key)
+ {
+ return _repositoriesEndPoint.GetBuildStatusInfo(logger, _accountName, _repository, revision, key);
+ }
+
///
/// Used to update the current status of a build status object on the specific commit.
///
@@ -270,6 +531,21 @@ public object ChangeBuildStatusInfo(string revision, string key, BuildInfo build
return _repositoriesEndPoint.ChangeBuildStatusInfo(_accountName, _repository, revision, key, buildInfo);
}
+ ///
+ /// Used to update the current status of a build status object on the specific commit.
+ /// With Logging
+ ///
+ ///
+ /// The commit's SHA1
+ /// The build status' unique key
+ /// The new commit status object
+ ///
+ /// /// This operation can also be used to change other properties of the build status: state, name, description, url, refname. The key cannot be changed.
+ public object ChangeBuildStatusInfo(ILogger logger, string revision, string key, BuildInfo buildInfo)
+ {
+ return _repositoriesEndPoint.ChangeBuildStatusInfo(logger, _accountName, _repository, revision, key, buildInfo);
+ }
+
#endregion
#region Default Reviewer Resource
@@ -284,6 +560,20 @@ public object PutDefaultReviewer(string targetUsername)
return _repositoriesEndPoint.PutDefaultReviewer(_accountName, _repository, targetUsername);
}
+ ///
+ /// Adds a user as the default review for pull requests on a repository.
+ /// With Logging
+ ///
+ ///
+ /// The user to add as the default reviewer.
+ ///
+ public object PutDefaultReviewer(ILogger logger, string targetUsername)
+ {
+ return _repositoriesEndPoint.PutDefaultReviewer(logger, _accountName, _repository, targetUsername);
+ }
+
#endregion
+
+
}
}
\ No newline at end of file
diff --git a/SharpBucket/V2/EndPoints/TeamsEndPoint.cs b/SharpBucket/V2/EndPoints/TeamsEndPoint.cs
index 5f3ec930..981cb860 100644
--- a/SharpBucket/V2/EndPoints/TeamsEndPoint.cs
+++ b/SharpBucket/V2/EndPoints/TeamsEndPoint.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Dynamic;
+using Serilog;
using SharpBucket.V2.Pocos;
namespace SharpBucket.V2.EndPoints
@@ -24,6 +25,20 @@ public List GetUserTeams(int max = 0)
//return _sharpBucketV2.Get>(null, "teams/", parameters);
}
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ public List GetUserTeams(ILogger logger, int max = 0)
+ {
+ dynamic parameters = new ExpandoObject();
+ parameters.role = "member";
+ return GetPaginatedValues(logger, "teams/", max, parameters);
+ //return _sharpBucketV2.Get>(null, "teams/", parameters);
+ }
+
///
/// Gets the public information associated with a team.
/// If the team's profile is private, the caller must be authenticated and authorized to view this information.
@@ -34,6 +49,18 @@ public Team GetProfile()
return _sharpBucketV2.Get(new Team(), _baseUrl);
}
+ ///
+ /// Gets the public information associated with a team.
+ /// If the team's profile is private, the caller must be authenticated and authorized to view this information.
+ /// With Logging
+ ///
+ ///
+ ///
+ public Team GetProfile(ILogger logger)
+ {
+ return _sharpBucketV2.Get(logger, new Team(), _baseUrl);
+ }
+
///
/// Gets the team's members.
///
@@ -45,6 +72,19 @@ public List ListMembers(int max = 0)
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// Gets the team's members.
+ /// With Logging
+ ///
+ ///
+ /// The maximum number of items to return. 0 returns all items.
+ ///
+ public List ListMembers(ILogger logger, int max = 0)
+ {
+ var overrideUrl = _baseUrl + "members/";
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
///
/// Gets the list of accounts following the team.
///
@@ -56,6 +96,19 @@ public List ListFollowers(int max = 0)
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// Gets the list of accounts following the team.
+ /// With Logging
+ ///
+ ///
+ /// The maximum number of items to return. 0 returns all items.
+ ///
+ public List ListFollowers(ILogger logger, int max = 0)
+ {
+ var overrideUrl = _baseUrl + "followers/";
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
///
/// Gets a list of accounts the team is following.
///
@@ -67,6 +120,19 @@ public List ListFollowing(int max = 0)
return GetPaginatedValues(overrideUrl, max);
}
+ ///
+ /// Gets a list of accounts the team is following.
+ /// With Logging
+ ///
+ ///
+ /// The maximum number of items to return. 0 returns all items.
+ ///
+ public List ListFollowing(ILogger logger, int max = 0)
+ {
+ var overrideUrl = _baseUrl + "following/";
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
///
/// Gets the list of the team's repositories.
/// Private repositories only appear on this list if the caller is authenticated and is authorized to view the repository.
@@ -78,5 +144,91 @@ public List ListRepositories(int max = 0)
var overrideUrl = _baseUrl + "repositories/";
return GetPaginatedValues(overrideUrl, max);
}
+
+ ///
+ /// Gets the list of the team's repositories.
+ /// Private repositories only appear on this list if the caller is authenticated and is authorized to view the repository.
+ /// With Logging
+ ///
+ ///
+ /// The maximum number of items to return. 0 returns all items.
+ ///
+ public List ListRepositories(ILogger logger, int max = 0)
+ {
+ var overrideUrl = _baseUrl + "repositories/";
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+
+ ///
+ /// Get's the list of the team's projects.
+ /// A paginated list of projects that belong to the specified team.
+ ///
+ ///
+ ///
+ public List ListProjects(int max = 0)
+ {
+ var overrideUrl = _baseUrl + "projects/";
+ return GetPaginatedValues(overrideUrl, max);
+ }
+
+ ///
+ /// With Logging
+ /// Get's the list of the team's projects.
+ /// A paginated list of projects that belong to the specified team.
+ ///
+ ///
+ ///
+ ///
+ public List ListProjects(ILogger logger, int max = 0)
+ {
+ var overrideUrl = _baseUrl + "projects/";
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
+ ///
+ /// ProjectPostParams contains solely the required parameters for posting a project
+ ///
+ ///
+ ///
+ public ProjectPostParams PostProject(ProjectPostParams project)
+ {
+ var overrideUrl = _baseUrl + "projects/";
+ return _sharpBucketV2.Post(project, overrideUrl);
+ }
+
+ ///
+ /// With Logging
+ /// ProjectPostParams contains solely the required parameters for posting a project
+ ///
+ ///
+ ///
+ ///
+ public ProjectPostParams PostProject(ILogger logger, ProjectPostParams project)
+ {
+ var overrideUrl = _baseUrl + "projects/";
+ return _sharpBucketV2.Post(logger, project, overrideUrl);
+ }
+ ///
+ /// Get a project by using
+ ///
+ ///
+ ///
+ public Project GetProject(string projectKey)
+ {
+ var overrideUrl = _baseUrl + "projects/" + projectKey;
+ return _sharpBucketV2.Get(new Project(), overrideUrl);
+ }
+
+ ///
+ /// With Logging
+ /// Get a project by using project key
+ ///
+ ///
+ ///
+ ///
+ public Project GetProject(ILogger logger, string projectKey)
+ {
+ var overrideUrl = _baseUrl + "projects/" + projectKey;
+ return _sharpBucketV2.Get(logger, new Project(), overrideUrl);
+ }
}
}
\ No newline at end of file
diff --git a/SharpBucket/V2/EndPoints/UserEndpoint.cs b/SharpBucket/V2/EndPoints/UserEndpoint.cs
index 7b1ba8fe..8b7bcae4 100644
--- a/SharpBucket/V2/EndPoints/UserEndpoint.cs
+++ b/SharpBucket/V2/EndPoints/UserEndpoint.cs
@@ -1,4 +1,6 @@
-using SharpBucket.V2.Pocos;
+using System.Collections.Generic;
+using Serilog;
+using SharpBucket.V2.Pocos;
namespace SharpBucket.V2.EndPoints
{
@@ -13,5 +15,37 @@ public User GetUser()
{
return _sharpBucketV2.Get(null, _baseUrl);
}
+
+ ///
+ /// Get With Logging
+ ///
+ ///
+ ///
+ public User GetUser(ILogger logger)
+ {
+ return _sharpBucketV2.Get(logger, null, _baseUrl);
+ }
+
+ ///
+ /// Returns all the authenticated user's email addresses. Both confirmed and unconfirmed.
+ ///
+ ///
+ public List GetEmails(int max = 0)
+ {
+ var overrideUrl = _baseUrl + "emails/";
+ return GetPaginatedValues(overrideUrl, max);
+ }
+
+ ///
+ /// With Logging
+ ///
+ ///
+ ///
+ ///
+ public object GetEmails(ILogger logger, int max = 0)
+ {
+ var overrideUrl = _baseUrl + "emails/";
+ return GetPaginatedValues(logger, overrideUrl, max);
+ }
}
}
\ No newline at end of file
diff --git a/SharpBucket/V2/Pocos/Branch.cs b/SharpBucket/V2/Pocos/Branch.cs
index 5f07e6dc..8dfff0df 100644
--- a/SharpBucket/V2/Pocos/Branch.cs
+++ b/SharpBucket/V2/Pocos/Branch.cs
@@ -3,5 +3,13 @@
public class Branch
{
public string name { get; set; }
+ public string message { get; set; }
+ public string author { get; set; }
+ public string parents { get; set; }
+ public string files { get; set; }
+ public string branch { get; set; }
+ public string type { get; set; }
+ public string path { get; set; }
+ public Links links { get; set; }
}
}
\ No newline at end of file
diff --git a/SharpBucket/V2/Pocos/BranchRestriction.cs b/SharpBucket/V2/Pocos/BranchRestriction.cs
index f3ad0084..34c3d8c1 100644
--- a/SharpBucket/V2/Pocos/BranchRestriction.cs
+++ b/SharpBucket/V2/Pocos/BranchRestriction.cs
@@ -4,11 +4,13 @@ namespace SharpBucket.V2.Pocos
{
public class BranchRestriction
{
- public List