For example I want to receive only project names:
https://gitlab.com/api/v4/groups/:id/projects?fields=name
Is that possible?
That's not possible in the REST API. But, GitLab is working on GraphQL support, and you'd be able to express that in GraphQL.
https://docs.gitlab.com/ee/api/graphql/
To iterate on Vonc & King Chung Huang 's answers, using the following GraphQL query, you can get only the name field of the projects inside your group :
{
group(fullPath: "your_group_name") {
projects {
nodes {
name
}
}
}
}
You can go to the following URL : https://$gitlab_url/-/graphql-explorer and past the above query
Using curl & jq :
gitlab_url=<your gitlab host>
access_token=<your access token>
group_name=<your group name>
curl -s -H "Authorization: Bearer $access_token" \
-H "Content-Type:application/json" \
-d '{
"query": "{ group(fullPath: \"'$group_name'\") { projects { nodes { name }}}}"
}' "https://$gitlab_url/api/graphql" | jq '.'
GitLab 1.11 (May 2019) has now introduced a "basic support for group GraphQL queries "
GraphQL APIs allows users to request exactly the data they need, making it possible to get all required data in a limited number of requests.
In this release, GitLab is now supporting basic group information support in the GraphQL API.
See Issue 60786 and documentation: "Available queries"
A first iteration of a GraphQL API includes the following queries
project : Within a project it is also possible to fetch a mergeRequest by IID.
group : Only basic group information is currently supported.
Related
Line of my .gitlab-ci.yml
IID=$(curl --verbose --request GET --header "Content-Type: application/json" --header "PRIVATE-TOKEN: ${CI_PUSH_TOKEN}" ${APP_REPO_URL}/merge_requests?author_id=xxxxxxxx\&search=${CI_COMMIT_SHORT_SHA} | jq '.[0].iid')
output jq: error (at :0): Cannot index object with number
Please refer to the documentation on Merge requests API and How to use the API to construct a properly formed cURL request with GitLab API before piping the result into jq.
There are a few things going on with your query.
First of all, according to the documentation, the /merge_requests endpoint will
Get all merge requests the authenticated user has access to.
This means that APP_REPO_URL needs to be the GitLab instance URL followed by /api/v4 and not the URL of the specific project.
curl "https://gitlab.example.com/api/v4/merge_requests"
If you need all merge requests for a given project, then you can use
curl "https://gitlab.example.com/api/v4/projects/:id/merge_requests"
where :id is the id of your project. See more at List project merge requests
Then, the search attribute is expecting either a title or a description and not a commit SHA:
Search merge requests against their title and description
I have a doubt regarding how to tag the cluster of the job cluster in databricks via api.
I know that I can already tag a cluster and the job, but I wanted to tag the cluster of the cluster job, is this possible?
I tried to use the "jobs/update" endpoint to insert the tag in the job cluster and even inserting these fields it still gets the same error:
Example of request:
curl --location --request POST 'https://databricks.com/api/2.0/jobs/update' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{
"job_id": 123456789,
"new_settings": {
"job_clusters": [
{
"job_cluster_key": "test",
"new_cluster": {
"custom_tags": {"test": "123"}
}
}
]
}
}'
I want to tag the resource (cluster) within the cluster job, is it possible via api? Has anyone performed this action?
If you look into Jobs API documentation, you may see that you need to provide all configuration parameters for block that you're updating, not only changed nested fields. Basically, this API allows you to change only top-level fields of the job, and do it completely, not nested fields.
P.S. I'll ask docs team to provide clarification there.
How can I get the repo-language and topic for a Github Repo through the REST API. I looked at the documentation under - https://developer.github.com/v3/ , but could not get an answer.
Just found one way to do the search for topics as follows. Of course it needs a custom media type at moment.
From the documentation:
curl -H "Authentication: token TOKEN" \
-H "Accept: application/vnd.github.mercy-preview+json" \
https://api.github.com/search/repositories?q=topic:ruby+topic:rails
For the language, it is simply the URL like :
https://api.github.com/repos/postgres/pgadmin4/languages
I'm experiencing errors when trying to add users to a Gitlab project using the Gitlab API. I'm using Gitlab version 8.11.0 on CentOS 6.8 and I'm not sure if it is a bug or something I am doing wrong.
The following works fine and gives me a list of project members:
curl --header "PRIVATE-TOKEN: top_secret" "https://thegitlabserver.com/api/v3/projects/1/members"
but when trying to add a members with the following, I get an error message:
curl --request POST --header "PRIVATE-TOKEN: top_secret" "https://thegitlabserver.com/api/v3/projects/1/members/myusername?access_level=30"
{"error":"405 Not Allowed"}
Using the web interface I am able to add the user to the project.
It looks like the Gitlab API documentation was incorrect.
As it's a create action, you should send both the user ID and access levels as named parameters (like you would for creating any other resource).
So something like: https://thegitlabserver.com/api/v3/projects/1/members/?user_id=299&access_level=40
I am trying to develop an ios app using the newly published NEST api but bit lost with their native documentation.
Question:I could get an access token but do not know the thermostat endpoint to query and update "Away" state
Any pointers will be greatly appreciated ..
I'm presuming you intend to use REST to query and update the away state since you mentioned "endpoint"? If not the other alternative is to use the firebase API. This is documented in the introduction section
To get the away status you'll need to query the structure/s
curl -v -L https://developer-api.nest.com/structures?auth=<AUTH_TOKEN>
The response shows the away state in addition to the thermostats/smoke co alarms in that structure.
{
"g-9y-2xkHpBh1MGkVaqXOGJiKOB9MkoW1hhYyQk2vAunCK8a731jbg": {
"away": "home",
"country_code": "US",
"name": "Home",
"smoke_co_alarms": [
"0NBM7-QfoLwhMldZ2CoIkQ7hRJoe1Jye"
],
"structure_id": "g-9y-2xkHpBh1MGkVaqXOGJiKOB9MkoW1hhYyQk2vAunCK8a731jbg",
"thermostats": [
"GM6Z9JpSKU6_ua8AfD6WRA"
],
"time_zone": "America/Los_Angeles"
}
}
To update the away state you would need to use the PUT http verb:
curl -v -L -X PUT "https://developer-api.nest.com/structures/g-9y-2xkHpBh1MGkVaqXOGJiKOB9MkoW1hhYyQk2vAunCK8a731jbg?auth=<AUTH_TOKEN>" -H "Content-Type: application/json" -d '{"away":"away"}'
Note that the ID used in the path parameter is the structure ID returned in the get response.
Hope that helps
Nagesh