I would like to know if there is a way to get the languages (percentage per language) used in a project by using the API provided by GitLab. I checked their documentation but I didn't see anything about that or maybe I missed it.
I know that they use the Linguist library but I'm developping an application that's is not in Ruby and I'm looking for a way to integrate theses percentages.
As of 10.8.x, Gitlab added a new API entrypoint, exposing languages used in a specific repository.
Usage is straight forward :
curl --header "PRIVATE-TOKEN: <__ACCESS_TOKEN__>" https://gitlab.mydomain.com/api/v4/projects/<ID>/languages
docs : https://docs.gitlab.com/ee/api/projects.html#languages
Hope this helps!
Looks like there's no endpoint to do this right now as the data for language repartition is sent in inline javascript. But it might become available as they refactor the code (see this and this)
Related
I am new to web-app development and the reSolve framework I am using for the backend (javascript). Since the application will have multiple users with different authorizations, I am using the Authentication and Authorization module like described in the documentation plus some lines from the shopping-list-advanced example.
The problem I am facing now is, how to make the HTTP-request in order to actually authenticate a user (register/login and also, logout)?
Since I couldn't find anything in the documentation, I've been trying a POST-request to http://localhost:3000/register but it always just returned Access error: POST is not addressable by current executor. What am I missing?
Another problem, or rather unclarity: In the example shopping-list-advanced what is "ROOT_JWT_TOKEN" and what is it used for?
Thanks a lot in advance.
I found it myself - at least the general path for the HTTP-request (see marked comment in picture):
Picture was taken from: https://github.com/reimagined/resolve/tree/master/packages/modules/resolve-module-auth
I am trying to introduce URL versioning into my .Net Core WebAPI application. I am also using Swagger web tools for ease of use for users.
Now, while trying to introduce versioning into my application, I referenced the docs here: https://github.com/Microsoft/aspnet-api-versioning/wiki/New-Services-Quick-Start#aspnet-core
Now, I made following code changes into my code:
Startup.cs/ConfigureServices I added code below:
services.AddApiVersioning(options => {
options.AssumeDefaultVersionWhenUnspecified = true;
});
Now, my controller annotations before any kind of versioning was added, looked like below:
[Produces("application/json")]
[Route("api/controllerName")]
and produces a URL which looks like something below:
http://localhost:12003/swagger/#!/Workspace/GetAll
Now, I added annotations below to enable api versioning:
. [ApiVersion("1.0")]
[Produces("application/json")]
[Route("api/v{version:apiVersion}/workspace")]
and now when I click on the same method listed in my swagger UI
the url looks like below:
http://localhost:12003/swagger/#!/controllername/ApiV_versionGetAll
While what I was expecting was something like:
http://localhost:12003/swagger/#!/controllername/V1.0/GetAll
Also on my swagger it is now asking me explicitly about entering version number. So I think my question boils down to two major points:
How I can I fix my URL? and what am I doing wrong?
Why is swagger now asking me to enter version number in API UI when I have explicitly stated that the version is going to be 1.0 in the annotation of the controller?
What you are missing is the complementary package for API versioning that supports an API version-aware API Explorer:
https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer
Install-Package Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer
The API Explorer is how Swagger generators like Swashbuckle do all their work. The source and links are also available in the API versioning repo.
To achieve the result you want, you need to configure API version substitution in the URL:
services.AddMvcCore().AddVersionedApiExplorer( options => options.SubstituteApiVersionInUrl = true );
Note: that the call the AddMvcCore() is no longer required in API Versioning 3.0+
Documentation and samples are available in the official API versioning repo. I recommend reviewing the API Documentation wiki topic:
https://github.com/Microsoft/aspnet-api-versioning/wiki/API-Documentation
The accepted answer extends this package, which is fine as long as it stay up-to-date with the flavor of API versioning you are using. API Versioning always ships compatible API Explorer extensions on every release.
Setting up api versioning with swagger is indeed a tricky thing as it is lot's of pieces that need to be setup correctly.
Luckily for us, there's a great nuget packages called SwashbuckleAspNetVersioningShim which solves this in an excellent way.
Add it
Install-Package SwashbuckleAspNetVersioningShim -Version 2.2.1
Then follow the readme here
I've got a program which creates JIRA issues using the jira-rest-api supported by Atlassian.
What I'd like to do is to create a link within the issue to an external URL (actually a presigned Amazon S3 link).
At the REST level this should be doable with a POST request to the Jira api to create a remoteLink. However I cannot find methods in the client APIs or a RemoteLink dto in the Java library.
Nor does the Java library appear to give any access to lower level REST handlers.
Now, I could set up my own REST handling code, going right back to the endpoint URL and authentication, but that's messy, when most of the code the code should already be there. Also I can't clearly see which json fields are required, and which not can be left to the API.
Am I overlooking something obvious in the documentation? I can't even seem to locate source for the client implementation, only the interface layer.
My current code is using version 3.0.6 of the api, but I've just checked v4 (which seems to be the latest on offer) and there's still no RemoteLink support.
Have you tried with these?
Server: https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/?_ga=2.26380925.1321063199.1523351418-1788196903.1491202928#api/2/issue-deleteRemoteIssueLinkById
Cloud: https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-remotelink-linkId-delete
I have a PHP application which, unfortunately, already uses the 1.1.4 version of the Google Client API, and I am unable to change that, which makes the 2.X version of the Google PHP Sheets API unavailable to me.
However, I'm hoping to be able to use the Google Sheets REST API directly, making my own curl calls (using Guzzle if that's at all interesting).
I'm brand new to the Google API and I've been all over their documentation, but I haven't been able to figure out how to do some basic things.
For the purposes of this question I want to simply create a new Google spreadsheet via the API, from a tool like POSTman.
I get that I first have to obtain an OAuth2 token via https://www.googleapis.com/auth/spreadsheets. The problem is that I can't quite figure out what to pass this call. I'm assuming it requires a GET since POST returns an error saying that method is unavailable.
Once I get that token, how do I use it when I POST to https://sheets.googleapis.com/v4/spreadsheets
Can someone provide a very basic example of the calls I might make directly to simply create a very basic default spreadsheet?
Or am I thinking about this all wrong? All help is appreciated.
If you already have an OAuth2 access token, you can pass it in the "Authorization" header:
curl -L -d '{}' \
-H "Authorization: Bearer <INSERT ACCESS TOKEN HERE>" \
-H 'Content-Type: application/json' \
https://sheets.googleapis.com/v4/spreadsheets
I just verified that curl command creates a new sheet.
Unfortunately as you already indicated, that's probably the simple part, and Getting an OAuth2 access token is more challenging.
Here's a (relatively painful, unfortunately) approach I use sometimes:
You should first create your own project in the API Console or Cloud Platform console, and configure it for your own OAuth2 client id and client secret.
Next, for just playing around, from the Google OAuth2 Developer Playground at https://developers.google.com/oauthplayground/, set your Client Id and Client Secret under the "OAuth 2.0 configuration" (it's the Settings icon - the little gear in the top right). The places to enter those will be hidden until you check "Use your own OAuth credentials". You can then get an access token, with the scopes https://www.googleapis.com/auth/spreadsheets and https://www.googleapis.com/auth/drive, by following the steps on the left.
For more playing around, you could then construct the POST right in step 3, or use the access token from Step 2 in the curl command above.
Best of luck - it's tricky stuff to get the auth parts right. There are lots of moving parts, and I'm just illustrating the high points here.
Tragedy about the library issue -- the PHP Quick Start appears to deal with the auth relatively cleanly.
Tim
Here's the official spreadsheets.create reference. Here's a list of Sheets API Samples. I would suggest that you leave the current version you're using and play with the PHP Quickstarts just so you can have a grasp of how it works.
This is going to be less than satisfying, but after fighting with it a while I looked to see if I could go against the premise of my question: That I couldn't upgrade to the latest Google Sheets PHP API.
As it turns out there was a way. That made all of this a lot easier.
Google's documentation is frustratingly incomplete, but I managed to get it all working anyway. Both of you gave me key pointers. Thanks for your help.
I need to hit this endpoint as part of an assessment, I have tried having a looking online and I would ideally like to do this just by using the browser console.
This is my task:
Your task is to write some code (eg. console, html form, javascript, python etc.) to hit 2 API endpoints. You can use any language, framework, tool or library. The result of each endpoint will give you instructions on how to proceed. The first endpoint is /api/Step1 and requires a GET verb and a parameter value=40
I am really trying to understand how to do this but all of the things I have read have not worked.
Any help would be greatly appreciated.
[Postman]
http://i.stack.imgur.com/DA5Oq.png
You should make sure you get the idea of what an API is, and you can read this for the queries.
That said, you are looking to send a GET http request to the url /api/Step1?value=40. You can to this using a tool like Postman on Chrome, but there are other equivalents for other browsers.
If you are using osx/linux, you can look up the command curl on google to see how to do a GET request from the terminal, or check this SO question.
Sending a GET request is quite easy. You can use curl and php for example. If you google it, you can find examples.
Giving a parameter is easy like this: /api/Step1?value=40