jlouros / stashapicsharp Goto Github PK
View Code? Open in Web Editor NEW[Atlassian] Bitbucket Server/Stash API wrapper built in C#
License: MIT License
[Atlassian] Bitbucket Server/Stash API wrapper built in C#
License: MIT License
In December V1 will go from deprecated to unsupported.
BitBucket users can create a personal token to authenticate themselves without providing their user/password.
This is a scenario that we are willing to use. I've tried to modify the code for a pull request, but the constructors parameters of both StashClient and HttpCommunicationWorker are only string and conflict between Basic and Bearer authentication scenario. Any guidance on how you see doing it that you feel comfortable?
Thanks
Currently using .NET Core 2.0, and I can't find the Atlassian.Stash
namespace. I can't find the StashClient
either. It looks as if it isn't exposed properly.
Use Azure Pipelines to:
Between step 1) and 2) we need to properly configure Bitbucket. A major inconvenience is license lifetime, at the moment it expires every 3 months.
Associated PR: #56
Hi,
I'm using VS 2012 with .NET 4.0, when installing nuget package (Install-Package Atlassian.Stash.Api -Version 1.0.15) i see the dependencies for Newtonsoft.Json (≥ 6.0.8) and Microsoft.AspNet.WebApi.Client (≥ 5.2.3) is using .NET framework 4.5. do you have backward compatible .NET framework stash api for .NET 4.0?
Cheers,
KS
Are there any plans to implement the comments API
Please can you update this to align with the .Net Core reference... 11.02.
The one referenced is so old it causes reference errors when your project already contains a later version - the binding redirects don't work.
This a feature suggestion: the ability to use the StashClient to run some BitBucket API commands/url that are not currently supported by this API. This would leverage the authentication and base URL from the client.
As an example, I could use the compare BB API with the client while the implementation is done ( #35 )
How do I get pull requests for a repository?
It doesn't seem to be possible to use the PUT
variants for pull requests to update them. Is that correct?
GetTAsync returns a list of projects. It should return a single project.
var stashClient = new StashClient(...);
stashClient.GetTAsync<Project> (...)//This returns a list of projects, it should return a single project.
Something like this should return a list of projects
stashClient.GetTAsync<List<Project>>(...)
REST client encountered an error: Value was either too large or too small for a UInt64.
Cannot debug this. Has htis been encountered before?
issue reported by @jhallam3 and imported from jlouros/BitBucketServerCSharp#1
This project was developed uniquely with BitBucket Server in mind (on-premises version of BitBucket). Even though the API might be similar, the current implementation would have to be thoroughly tested. To begin with we need to ensure how to handle authentication.
Additional research required.
I see that the StashApiCSharp supports basic authentication using string for password . wouldn't it better to add support for SecureString in order to avoid possible risk of exposing sensitive data in managed memory?
I was thinking to add a new
public HttpCommunicationWorker(string baseUrl, string username, SecureString password)
{
var httpClientHandler = new HttpClientHandler
{
Credentials = new NetworkCredential(username, password)
};
_httpClient = new HttpClient(httpClientHandler) {BaseAddress = new Uri(baseUrl)};
}
Thanks,
Frank
I would like to mock this API for unit tests. Are you open to the idea of adding interfaces to the StashClient and API objects? I would be willing to create a PR.
I am trying to get all of the forks given a specific repo and wasn't able to find a way to do that through the API. https://developer.atlassian.com/static/rest/stash/3.11.3/stash-rest.html#idp1673824 gives the details of the REST call. I was able to verify that this worked as expected using a raw call to the REST method, but it doesn't look like the corresponding wrappers have been written in this API.
The HttpCommunicationWorker makes a new instance of the HttpClient every request. This is a bad practice, because it's intended to live for a longer and preferably reused for every request. @jlouros I would like to fix it, but I thought first run it through you to agree on this problem.
Sources:
https://blogs.msdn.microsoft.com/shacorn/2016/10/21/best-practices-for-using-httpclient-on-services/
https://docs.microsoft.com/en-us/azure/architecture/antipatterns/improper-instantiation/
Is it possible to merge pull requests, because i can't see that functionality?
I'm using this in a .NET Core project, which is targeting .NET Framework 4.5.2 and from this library (version 3.0.5) I'm getting errors that it's trying to load the above mentioned dependency - which doesn't exist on the machine.
Hi.
Could you please add support for creating tags?
URL (post): rest/git/1.0/projects/{projectKey}/repos/{repositorySlug}/tags
https://developer.atlassian.com/static/rest/stash/3.11.3/stash-scm-git-rest.html
Unable to Retrieve branch permission group from bitbucket as more then 25 groups exists for repository. Branches.GetPermissions does not allow setting of RequestOptions to allow paging or a larger number of results.
Repository.GetFiles() currently gets a list of all files in the repo, the rest API supports a path parameter that lets you get files in a sub-directory.
I see that the StashApiCSharp supports basic authentication. Please add support to add windows authentication as well. Such that we don't have to give our user name and passwords.
p.s: If I find time i'll implement it and issue a pull request.
Thanks,
Sriram
When can we expect a release for .Net Core framework?
When requesting Repositories.GetFileContents with a path of a file located in a subfolder it returns Bad Request. After inspecting it seems that the problem is related to the encoding of '/'. This is an example call returning bad request:
http://stashserverurl/rest/api/1.0/projects/my-project/repos/my-repo/browse/Build%2Fpackages.config
It works if %2F is replaced by /
The current implementation does not support url's like this one: scm.company.com/stash. It assumes all deployments are on the root of the domain (like scm.company.com)
In order for those url's to be supported you need to add a trailing slash in the base url and then remove the starting slash from the requestUrl.
I have hacked this to make it work but it's not pretty in the current design
Since Atlassian has renamed Stash to Bitbucket Server shouldn't this repo also be renamed so it is easier for people to find it?
E.g. BitbucketApiCSharp or BitbucketServerApiCSharp
for each supported framework, we should automatically generate the appropriate packages dependencies.
At the moment, dependencies are hardcoded in the .nuspec file
When creating a pull request via PullRequests.Create if the specified from branch / to branch is not found, bitbucket will return 404 not found. But the contents of the response will be a JSON structure that explains what was not found.
The issue is this JSON response is never read if the HTTP status code is 404.
The exception thrown is:
POST operation unsuccessful. Got HTTP status code 404.
I have modified a local checkout of the code to add reading the response data, which provides me the JSON error details as text in the exception:
Modified code - HttpCommunicationWorker, Line 97:
string error = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new Exception(string.Format("POST operation unsuccessful. Got HTTP status code '{0}' \nContent:\n{1}", httpResponse.StatusCode, error));
This is not ideal as it would be nice to deserialize the JSON error response to some sort of class structure.
Thanks.
I'm using this API for gathering some statistics on our BitBucket server for my team and I wanted to retrieved all commits (distinct across all branches).
Based on this answer, does a compare functionality or a GetAllCommits in the Branches API could be implemented?
What approach do you prefer? I may try to tackle it and submit a PR.
As per the documentation: https://developer.atlassian.com/static/rest/stash/3.11.3/stash-rest.html#idp1513136
The commits endpoint can accept some additional parameters that are not currently supported
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.