Gitalb api: Difference between revisions
Jump to navigation
Jump to search
(Created page with "===== Basic API Calls for Gitlab ===== <pre> curl -L "https://gitlab.iwillfearnoevil.com/api/v4/projects" | jq '.' Partial return: { "id": 17, "description": "Find...") |
|||
| (5 intermediate revisions by the same user not shown) | |||
| Line 35: | Line 35: | ||
} | } | ||
</pre> | </pre> | ||
===== Working Example ===== | |||
This is using an APPLICATION PAT, not a user PAT. Issues seem to arise with user PAT. Likely issue with missed setting int GUI. | |||
<pre> | |||
curl -s -q --request GET --header "PRIVATE-TOKEN: <TOKEN>" -L "https://gitlab.iwillfearnoevil.com/api/v4/notification_settings" | jq '.' | |||
{ | |||
"level": "participating", | |||
"notification_email": "project56_bot@noreply.gitlab01.iwillfearnoevil.com" | |||
} | |||
</pre> | |||
===== Pulling Snippets ===== | |||
<pre> | |||
curl -s -q --request GET --header "PRIVATE-TOKEN: <TOKEN>" -L "https://gitlab.iwillfearnoevil.com/api/v4/snippets/1" | jq '.' | |||
{ | |||
"id": 1, | |||
"title": "bash getopts", | |||
"description": null, | |||
"visibility": "public", | |||
"updated_at": "2016-06-19T02:20:53.011Z", | |||
"created_at": "2016-06-19T02:20:53.011Z", | |||
"project_id": null, | |||
"web_url": "https://gitlab01.iwillfearnoevil.com/-/snippets/1", | |||
"raw_url": "https://gitlab01.iwillfearnoevil.com/-/snippets/1/raw", | |||
"ssh_url_to_repo": "git@gitlab01.iwillfearnoevil.com:snippets/1.git", | |||
"http_url_to_repo": "https://gitlab01.iwillfearnoevil.com/snippets/1.git", | |||
"author": { | |||
"id": 2, | |||
"username": "chubbard", | |||
"name": "Chris Hubbard", | |||
"state": "active", | |||
"avatar_url": "https://secure.gravatar.com/avatar/cf780bb1a19cb5dc118c6b3c5a7e8f9c?s=80&d=identicon", | |||
"web_url": "https://gitlab01.iwillfearnoevil.com/chubbard" | |||
}, | |||
"file_name": "snippetfile1.txt", | |||
"files": [ | |||
{ | |||
"path": "snippetfile1.txt", | |||
"raw_url": "https://gitlab01.iwillfearnoevil.com/-/snippets/1/raw/master/snippetfile1.txt" | |||
} | |||
] | |||
} | |||
</pre> | |||
===== Gitlab Alerts ===== | |||
#Create a webhook in Project >> Settings >> Monitor >> Alerts | |||
#You will need both the URL, AND the key | |||
## Success returns json: [{"iid":2,"title":"Incident title"}] | |||
## curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${KEY}" -L ${URL} --data '@test.json' | |||
### https://gitlab01.iwillfearnoevil.com/monitoring/slimframework/nmsApi/-/alert_management/2/details#/overview | |||
Latest revision as of 16:17, 16 January 2024
Basic API Calls for Gitlab
curl -L "https://gitlab.iwillfearnoevil.com/api/v4/projects" | jq '.'
Partial return:
{
"id": 17,
"description": "Find out all the things when invoked",
"name": "discovery",
"name_with_namespace": "monitoring / discovery",
"path": "discovery",
"path_with_namespace": "monitoring/discovery",
"created_at": "2016-06-18T21:35:07.253Z",
"default_branch": "master",
"tag_list": [],
"topics": [],
"ssh_url_to_repo": "git@gitlab01.iwillfearnoevil.com:monitoring/discovery.git",
"http_url_to_repo": "https://gitlab01.iwillfearnoevil.com/monitoring/discovery.git",
"web_url": "https://gitlab01.iwillfearnoevil.com/monitoring/discovery",
"readme_url": null,
"avatar_url": null,
"forks_count": 0,
"star_count": 0,
"last_activity_at": "2016-06-18T21:57:23.124Z",
"namespace": {
"id": 4,
"name": "monitoring",
"path": "monitoring",
"kind": "group",
"full_path": "monitoring",
"parent_id": null,
"avatar_url": null,
"web_url": "https://gitlab01.iwillfearnoevil.com/groups/monitoring"
}
}
Working Example
This is using an APPLICATION PAT, not a user PAT. Issues seem to arise with user PAT. Likely issue with missed setting int GUI.
curl -s -q --request GET --header "PRIVATE-TOKEN: <TOKEN>" -L "https://gitlab.iwillfearnoevil.com/api/v4/notification_settings" | jq '.'
{
"level": "participating",
"notification_email": "project56_bot@noreply.gitlab01.iwillfearnoevil.com"
}
Pulling Snippets
curl -s -q --request GET --header "PRIVATE-TOKEN: <TOKEN>" -L "https://gitlab.iwillfearnoevil.com/api/v4/snippets/1" | jq '.'
{
"id": 1,
"title": "bash getopts",
"description": null,
"visibility": "public",
"updated_at": "2016-06-19T02:20:53.011Z",
"created_at": "2016-06-19T02:20:53.011Z",
"project_id": null,
"web_url": "https://gitlab01.iwillfearnoevil.com/-/snippets/1",
"raw_url": "https://gitlab01.iwillfearnoevil.com/-/snippets/1/raw",
"ssh_url_to_repo": "git@gitlab01.iwillfearnoevil.com:snippets/1.git",
"http_url_to_repo": "https://gitlab01.iwillfearnoevil.com/snippets/1.git",
"author": {
"id": 2,
"username": "chubbard",
"name": "Chris Hubbard",
"state": "active",
"avatar_url": "https://secure.gravatar.com/avatar/cf780bb1a19cb5dc118c6b3c5a7e8f9c?s=80&d=identicon",
"web_url": "https://gitlab01.iwillfearnoevil.com/chubbard"
},
"file_name": "snippetfile1.txt",
"files": [
{
"path": "snippetfile1.txt",
"raw_url": "https://gitlab01.iwillfearnoevil.com/-/snippets/1/raw/master/snippetfile1.txt"
}
]
}
Gitlab Alerts
- Create a webhook in Project >> Settings >> Monitor >> Alerts
- You will need both the URL, AND the key
- Success returns json: [{"iid":2,"title":"Incident title"}]
- curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${KEY}" -L ${URL} --data '@test.json'